Java list Interface Usage

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.