A collection of interviews arraylist hashmap

LinkedList bottom layer is a doubly linked list (different parts of element distribution in the memory), in each node record position (i.e., the target domain) of a node, insert / delete fast elements only associated with hand pointer field (pointer field breakup, each there are two pointers nodes domain) to

List structure, when the data query, the query can only start from the first element, next pointer to traverse the list one by one until you find echoed elements. Move the pointer process is very time-consuming, slow queries. 

 

The ArrayList (creates contiguous memory region, continuous storage elements) underlying array is implemented, the principle of expansion, the default size is 10 (JDK8 source), the first expansion of 1.5 × 10 +1 = 16

Queries faster , find the first element, according to the number of intervals, you can find what you want. And the ArrayList remove elements, because of the index, so the index have to move forward. Time-consuming

LinkedList  and  ArrayList  are not safe.

synchronized keyword modified method or block of code, only one thread is executed at any time

 

hashmap principle, doubly linked list array +  

Arrays used to store each entry, 

 

Are abstract classes and interfaces can not be instantiated, interface or inherit the abstract classes implement all abstract methods must be overridden, jdk1.8 interfaces may be specific method of the method body

static/default String say() { return "hello"}

Published 78 original articles · won praise 12 · views 120 000 +

Guess you like

Origin blog.csdn.net/qq_29883183/article/details/102917398