3:42 pm - Tuesday November 17, 6905

Stack Example Program for iterator()

CANDID INDUSTRIAL TRAINING -- CHENNAI
Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044
/**
*@author :CandidJava.com
*@descriptions : This program explain the function and use of iterator() .
*/
import java.io.*;
import java.util.*;
public  class StackIterator
{
public static void main(String arg[])throws Exception
{
Stack s=new Stack();//to create object for Stack class
s.add(10);//to add an element in Stack
s.add(20);//to add an element in Stack
s.add(30);//to add an element in Stack
s.add(40);//to add an element in Stack
s.add(50);//to add an element in Stack
Iterator it=s.iterator();//to create object for Iterator interface
while(it.hasNext())
{
System.out.println(it.next());//to return next element of the list
}
}
}

OUTPUT:
10
20
30
40
50

BACK

Filed in: Z-A All Java Codes

Comments are closed.