A List keeps it elements in the order in which they were added. : List « Utility Classes « SCJP

Home
SCJP
1.Java Source And Data Type
2.Operators
3.Modifiers
4.Type Casting
5.Statements
6.Object Oriented
7.Thread
8.Utility Classes
9.File
SCJP » Utility Classes » List 
8.13.1.A List keeps it elements in the order in which they were added.
ArrayList, extends AbstractList, is roughly equivalent to the Vector class

ArrayList can expand as needed. 
ArrayList does not use synchronized methods.
ArrayList is somewhat faster than Vector.



import java.util.ArrayList;
import java.util.List;

public class MainClass {
  public static void main(String[] argv) {
    List<String> list = new ArrayList<String>();
    list.add("a");
    list.add("b");
    list.add("c");

    for (String s : list) {
      System.out.println(s);
    }
  }
}
a
b
c
8.13.List
8.13.1.A List keeps it elements in the order in which they were added.
8.13.2.List: void add(int index, Object x) Inserts x at index.
8.13.3.List: Object get(int index) Returns the element at index.
8.13.4.List: int indexOf(Object x) Returns the index of the first occurrence of x, or -1 if the List does not contain x.
8.13.5.Collection: Object remove(int index) Removes the element at index.
8.13.6.ListIterator extends the Iterator interface to support bidirectional iteration of lists.
8.13.7.Using Iterator for Lists
8.13.8.toArray() method
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.