collection family

Disclaimer: The materials used in this column are written by VIP students of Kaige Academy. Students have the right to remain anonymous and have the right to final interpretation of the article. Kaige Academy aims to promote VIP students to learn from each other based on public notes.

Collection family:

Introduction: It is composed of interfaces. Its highest interface is Collection, followed by List and Set, and Map. The purpose of applying for these interfaces is to think about standards and unity. As shown in the figure below, it contains branches of the family.

image

Collection family methods:
as shown below: Collection methods in it

image

image

Set: no method
List:
as shown below: it is a method in List

image

ArrayList:
as shown below: ArrayList has an int parameter passed in it, passing in 100 means the initialization length, which is the initial size of the array

image

Vector:
The following are the methods of Vector

image

Stack collection:
push into the stack, pop out of the stack, Peek who is currently going to pop out of the stack, an exception will be thrown if there is no back, and popping out of the stack is equivalent to deleting

image

LinkedList:
addFirst is added forward, addLast is added backward, getFirst gets the former, getLast gets the latter, removeFirst deletes the former, removeLst deletes the latter

image

HashSet:
If you add many s1s, it is still only one, because it cannot add duplicate values

image

TreeSet :
It is a sorted set. It is to be sorted when your data is added. If you add this Dog to it, it will report an error. It requires this class to be implemented in this interface before it can be sorted.

image

You have to implement this interface. If you are greater than it, return 1, if it is equal to it, return 0, and if it is less than it, return -1

image

image

Then sort by dog's age

image

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325428285&siteId=291194637