Delete Stack15.java
This commit is contained in:
31
Stack15.java
31
Stack15.java
@@ -1,31 +0,0 @@
|
|||||||
//15. write a java code to demonstrate stack
|
|
||||||
import java.util.*;
|
|
||||||
public class Stack15
|
|
||||||
{
|
|
||||||
public static void main(String[] args)
|
|
||||||
{
|
|
||||||
Stack<String> food = new Stack<String>();
|
|
||||||
food.push("Butter Chicken");
|
|
||||||
food.push("Dal Makhani");
|
|
||||||
food.push("Kadhai Paneer");
|
|
||||||
food.push("Prawns Koliwada");
|
|
||||||
food.push("Crab Soup");
|
|
||||||
Iterator<String> itr = food.iterator();
|
|
||||||
while(itr.hasNext());
|
|
||||||
{
|
|
||||||
System.out.println(itr.next());
|
|
||||||
}
|
|
||||||
String Food = food.peek();
|
|
||||||
System.out.println("The Top food item is: " +food);
|
|
||||||
|
|
||||||
food.pop();
|
|
||||||
System.out.println("After Pop:");
|
|
||||||
Iterator<String> newItr = food.iterator();
|
|
||||||
while(newItr.hasNext());
|
|
||||||
{
|
|
||||||
System.out.println(newItr.next());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user