first commit

This commit is contained in:
2026-02-26 12:59:05 +05:30
parent e261dbf9c3
commit 33575a6863
7 changed files with 128 additions and 0 deletions

23
TestJavaCollection4.java Normal file
View File

@@ -0,0 +1,23 @@
// Write a java code to demo stack
import java.util.*;
public class TestJavaCollection4{
public static void main(String args[]){
Stack<String> stack = new Stack<String>();
stack.push("Ayush");
stack.push("Garvit");
stack.push("Amit");
stack.push("Ashish");
stack.push("Garvit");
Iterator<String> 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);
}
}
}