Upload files to "/"
This commit is contained in:
18
LinkedList13b.java
Normal file
18
LinkedList13b.java
Normal file
@@ -0,0 +1,18 @@
|
||||
//program 13b
|
||||
import java.util.*;
|
||||
public class LinkedList13b
|
||||
{
|
||||
public static void main(String[] args)
|
||||
{
|
||||
LinkedList<String> name1=new LinkedList<String>();
|
||||
name1.add("Misa");
|
||||
name1.add("Aditya");
|
||||
name1.add("Aisha");
|
||||
name1.add("Aditya");
|
||||
Iterator<String> itr=name1.iterator();
|
||||
while(itr.hasNext())
|
||||
{
|
||||
System.out.println(itr.next());
|
||||
}
|
||||
}
|
||||
}
|
||||
31
Stack15.java
Normal file
31
Stack15.java
Normal file
@@ -0,0 +1,31 @@
|
||||
//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("\nButter 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("\nThe Top food item is: " +Food);
|
||||
|
||||
food.pop();
|
||||
System.out.println("\nAfter Pop:");
|
||||
Iterator<String> newItr = food.iterator();
|
||||
while(newItr.hasNext())
|
||||
{
|
||||
System.out.println(newItr.next());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user