It 18 Palm Job _java Foundation Day _ Collection

Source: Internet
Author: User

1, remove (int index); //Delete the element at the specified position

2, remove (Object o); //Delete the specified object and examine the rules for deleting objects?

3, RemoveAll (Collection col);//delete all elements in the specified collection.

4, contains (Object O); //Whether it contains

5, contains (Collection col);//Whether the collection is included.

---------------------------------------------------------------------------------

List coll=new ArrayList ();
Coll.add (New String ("Asdads"));
Coll.add (New String ("ASD"));
Coll.add (10);
if (Coll.contains ("Asdads")) {
Coll.remove ("Asdads"); Containers are iteratable when objects are deleted, the objects in the container are traversed, the Equals method of each object is called, and the reference to the object is deleted if the same
}

Collection coll2=new ArrayList ();
Coll2.add (10);
if (Coll.contains (COLL2))
Coll.removeall (coll);

It 18 Palm Job _java Foundation Day _ 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.