"DAY10" Learning notes about the collection

Source: Internet
Author: User

Auto-Boxing: Integer i = 12; //=== integer i = new Integer (12);

Automatic unpacking: Integer i = 12; i + +//=== i.parseint () = 12; ++

If the box is not automatically disassembled only int i=i.intvalue ();

System.out.print (I+4);


Wrapper class and basic type Difference

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

1. The wrapper class is an object, and the default value is null.

2. The basic data type of the digital type is 0.

3. The basic data type can be directly involved in the operation.


List: Lists, Interface ArrayList ()

Note: Arrays can only store basic data types, and collections can only store objects.


[] Array

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

Length/Width Property


String

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

Length ()//method.



Interface Collection

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

Size ()//method

IsEmpty () //==null?


Judging set validity

Col! = null && col.isempty ()

Contains (object obj)//Determines whether the specified object is included

List //ordered, repeatable


Set//unordered, non-repeating

Note: The collection interface has two sub-interfaces: List (lists), set (set)

Map//key-value KV pair

TIPS:

List: Can hold repeating elements, element access is ordered.

Set: Can not hold duplicate elements, element access is unordered.

First judge whether the hashcode is the same, if different, can be stored, if the same, and then determine whether the same object and the Equals method is the same.

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M00/82/14/wKiom1dK28PRut04AAGFbhUOJag952.png "title=" Picture 1.png "alt=" Wkiom1dk28prut04aagfbhuojag952.png "/>

instanceof

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

operator to determine whether the variable is an object of the specified type.

Boolean b = obj instanceof String;


/**

* Create collection, store String[tom,tomas,tomslee]

* Storage integer[100,200,300]

* storage student{name,sex,age, standard Javabean}[tom,tomas,tomslee]

*

*/



Arraylist//Array list, packed in pairs, accessed by subscript value.

LinkedList//Chain list,






This article from "Yehomlab" blog, reproduced please contact the author!

"DAY10" Learning notes about the 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.