List Common methods

Source: Internet
Author: User

 Packagelianxi1;Importjava.util.ArrayList;Importjava.util.Date;Importjava.util.List;Importorg.junit.Test; Public classtestlist {@Test Public voidtest1 () {List List=NewArrayList (); List.add (55);//first elementList.add (35.432); List.add ("RR"); List.add (NewStudent ("3001", "WU") ; The//student class must override the Equals method System.out.println (list); List.add (1, "Tian");//The collection is calculated starting at 0, actually inserting the element in the second position, moving the second and subsequent elements to the rightList.remove (2);     SYSTEM.OUT.PRINTLN (list); List.set (3,NewDate ());     SYSTEM.OUT.PRINTLN (list); List List2= List.sublist (0, 1);   System.out.println (LIST2); }}

Results:

[35.432, RR, Student [id=3001, Name=wu]]
[Tian, RR, Student [id=3001, Name=wu]]
[Tian, RR, Fri Dec 22:16:44 CST 2014]
[55]

LinkedList class: Implementing linked Lists for frequent insert and delete operations

Vector class: The old implementation class, thread is safe. Not now, basically.

List Common methods

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.