Added till 18th

This commit is contained in:
Aditya Tiwari
2026-02-12 15:07:02 +05:30
parent d3a9111632
commit 0d16f1cde6
31 changed files with 200 additions and 0 deletions

25
Stack15.java Normal file
View File

@@ -0,0 +1,25 @@
// write a java code to demonstrate Stack
import java.util.*;
public class Stack15 {
public static void main(String ar[]){
Stack<String> elec = new Stack<String>();
elec.push("fan");
elec.push("air conditioner");
elec.push("computer");
elec.push("iron");
elec.push("lights");
Iterator<String> itr = elec.iterator();
while(itr.hasNext()){
System.out.println(itr.next());
}
String topOfStack = elec.peek();
System.out.println("The top electrical item is : " + topOfStack);
elec.pop();
System.out.println("After Pop : ");
Iterator<String> newItr = elec.iterator();
while(newItr.hasNext()){
System.out.println(newItr.next());
}
}
}