Friday, 19 March 2021

Stack in Java

 import java.util.*;

class CL3

{

public static void main(String[] args)

{

Stack<String> A1=new Stack<String>();

A1.push("Ram");

A1.push("Raj");

A1.push("Raman");

A1.push("Rajan");

A1.pop();

Iterator itr=A1.iterator();

while(itr.hasNext())

{

System.out.println(itr.next());

}

}

}

No comments:

Post a Comment