Java Collection Framework Collection

Source: Internet
Author: User

 Packagecollection;Importjava.util.ArrayList;Importjava.util.List;ImportOrg.apache.log4j.Logger;Importorg.junit.Test;/*** <p> @ClassName: collectiontest01</p>* <p>description:java Collection </p>*/ Public classCollectionTest01 {Private StaticLogger Logger = Logger.getlogger (CollectionTest01.class); @Test Public voidtest01 () {List<String> List1 =NewArraylist<string>(); List<String> List2 =NewArraylist<string>(); List1.add ("123"); List1.add ("1234"); List1.add ("12345"); List1.add ("12354"); List1.add ("123456"); List1.add ("123457"); List2.add ("1231"); List2.add ("1234"); List2.add ("12345"); List2.add ("12354"); List2.add ("12346"); List2.add ("123458"); //1. Append the elements in the List2 to the List1, AddAll ()//List1.addall (LIST2); //2, remove from List1, List1 and list2 the same elements, RemoveAll ()//List1.removeall (LIST2); //3, remove from List1, List1 and List2 different elements (for the intersection of two sets), Retainall ()//List1.retainall (LIST2); //4. Does the list1 contain all the elements in the List2        Booleanb =List1.containsall (LIST2);        Logger.info (b);    Logger.info (List1); }    }

Java Collection Framework Collection

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.