Import java. util. List;
Import java. util. Collections list;
Import java. util. arraylist;
Public class listtest_1 {
Public static void main (string [] ARGs ){
System. Out. println ("the class is to test java. util. List ;");
List li = new vertex list ();
// List li = new arraylist ();
Li. Add ("");
Li. Add ("B ");
Li. Add ("C ");
Li. Add ("D ");
Li. Add ("e ");
Li. Add ("F ");
Li. Add (1, "1 ");
// Li. Add (9, "2"); the writing method is incorrect and there are no 9th locations
// Obtain the total number of elements
System. Out. println ("the size of element is:" + Li. Size ());
// Obtain the first element
System. Out. println ("the first element is:" + Li. Get (0) + "");
System. Out. println ("all of the element is :");
For (INT I = 0; I <li. Size (); I ++ ){
System. Out. println ("element" + I + ":" + Li. Get (I ));
}
}
/*
Running result
The class is to test java. util. List;
The size of element is: 7
The first element is:
All of the element is:
Element 0:
Element 1: 1
Element 2: B
Element 3: c
Element 4: d
Element 5: E
Element 6: F
*/
}
Reprinted from: http://www.lession.net/blog/466.html