For example,
How do I use this custom print method to display something in the main method?

public static void print(Stack<String> myStack ) { 
 int count = 1, sizeOfStack = myStack.size(); 
 System.out.println("\nYour stack has size: " + myStack.size()); 
 for (String myString : myStack) 
 {System.out.print(count + ". " + myString); 
 if(count!=sizeOfStack) System.out.print( " -> "); 
 else System.out.print( " :Last"); 
 count++; 

create an instance of the class Stack<String>, let's suppose it's called "theStack", then just pass that to the print method:
print(theStack);

Hi thanks. Can u please also tell me how I can Use a for loop to help the cook assemble a Stack of eight wheat pancakes. Complete the for loop and add the missing statement so the eight pancakes are placed on the stack.

public class PancakeTest {

      public static void main(String[] args) {
       Stack<String> pancakeStack= new Stack<String>();
       Scanner keyboard = new Scanner(System.in);
       //Bonus pancakes are either bluebery or strawberry. 
String buckwheat = "Buckwheat Pancake"; // Standard pancake 
String blueberry = "Blueberry Pancake"; // Bonus pancake 
String strawberry = "Strawberry Pancake"; // Bonus pancake 
//Use a for loop to help the cook assemble a Stack of eight buckwheat pancakes. Complete the for loop and add the missing statement so the eight pancakes are placed on the stack. 
for(int k = 1; k<=8 ; k++){

That's a very specific homework question, and the answer is one very short line of code. You should make a greater effort to solve it yourself, rather than ask us to help you cheat. Post what you have tried, and someone will help fromn there.

Yeah the little code that I came up with is ,

for(int k = 1; k<=8 ; k++){

// But im not sure if it's correct. Because I dont know how to use this for loops to cook a stack of eight Buckwheat pancakes

All you need the loop for is to count up to eight. Inside the loop you just need to create a new pancake and add it to the stack. The loop runs 8 times, so you create and add 8 panckaes.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.