Program Name: ArraylistIteratorTest
Date:March 2, 2009
Purpose: To create a program using array list and iterators.*/
import java.util.Iterator;
import java.util.ArrayList;
import java.util.Scanner;
public class ArrayListIteratorTest{
public static void main(String args[]){
Scanner scan=new Scanner(System.in);
String beauty="a";
ArrayList
list.add("flower");
list.add("bag");
list.add("dress");
list.add("phone");
System.out.println("My Favorite things : ");
Iterator
while (it.hasNext()) {
String flowers = it.next();
System.out.println(flowers);
}
}
}
Things I've learned in this exercise:
. I've learned that an array list is an array based implementation wherein the elements of the List can be easily accessed.
. Array List and Iterators allows duplication of data.
. Using these classes allows easy storage and retrieval of elements.
No comments:
Post a Comment