// Write a java code to demo stack import java.util.*; public class TestJavaCollection4{ public static void main(String args[]){ Stack stack = new Stack(); stack.push("Ayush"); stack.push("Garvit"); stack.push("Amit"); stack.push("Ashish"); stack.push("Garvit"); Iterator itr=stack.iterator(); while(itr.hasNext()){ System.out.println(itr.next()); } String topElement = stack.peek(); System.out.println("The top element of the stack is: "+ topElement); stack.pop() System.out.println("After POP"); for(String element : stack){ System.out.println(element); } } }