A detailed explanation of the ArrayList remove method

Source: Internet
Author: User

Brief description: ArrayList Remove method, if the parameter of remove () is int type, then regardless of the type of ArrayList is any type, is to remove the corresponding subscript object. I. Type is non-integer

arraylist<long> Non_intarr = new arraylist<> ();
Non_intarray.add (1L);
Non_intarray.add (2L);
Non_intarray.add (3L);
Non_intarray.add (4L);
System.out.println (Non_intarray.remove (1));

The result is: 2 (a long type) (an object with a value of 2 removed). two. Type is an integer type

list<integer> intarray = new arraylist<> ();
Intarray.add (1);
Intarray.add (2);
Intarray.add (3);
Intarray.add (4);
System.out.println (Intarray.remove (1));

The result is also: 2 (int type) (an object with a value of 2 removed). three. How do I remove an object in the type integer?

list<integer> intarray = new arraylist<> ();
Intarray.add (1);
Intarray.add (2);
Intarray.add (3);
Intarray.add (4);
System.out.println (Intarray.remove (Object) 1);

Can. (because: the ArrayList class of the Remove method implementation is to use the object to deal with)

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.