Thursday, 15 October 2015

Arraylist example in java

import java.util.*;
public class First {

public static void main(String[] args) {
// TODO Auto-generated method stub
ArrayList<String> obj = new ArrayList<String>();
obj.add("India");
obj.add("Bombay");
obj.add("Test");
Iterator it = obj.iterator();
while(it.hasNext()){
System.out.println("The value of arraylist is " +it.next());

}
}

}

output:-
The value of arraylist is India
The value of arraylist is Bombay
The value of arraylist is Test

No comments:

Post a Comment