Set of instructions

ArrayList, Vector, LinkedList storage properties and characteristics

name Underlying structure Thread Safety Scenes
arraylist Array Unsafe It is suitable for random search and traversal, not suitable for insertion and deletion
linklist Doubly linked list Unsafe Dynamically insert and delete data
Vector Array Safety It supports thread synchronization, slow

hashmap data structure?
Array + + red-black tree list
key is not the same no matter hanshcode collision,
with a variable hanshcode list, the list is greater than a length greater than 8 becomes red-black tree.
Hashmap expansion when to do?
The default value is 0.75 adFactor, that is, by default, the size of the array 16, then when the number of elements exceeds 16 hashmap size = 0.75 12 extended time to put an array of 2 16 = 32, i.e., doubling
List, Map, Set three interfaces, accessing elements, what are the differences?
list add (), ordered
map put (), disordered
Set add (), unordered
two objects the same value (x.equals (y) == true) , but it may have different hash code, this sentence right?
No, the two objects the same hash code value is the same
heap and stack What is the difference.
Heap, priority queues, FIFO
stack, advanced after a
difference in the Java stack and heap:
  Stack (stack) and heap (heap) are used to store data in Java where the Ram. Unlike C ++, Java automatically manage the stack and heap, the programmer can not directly set the stack or heap.
  Variables refer to variables and objects of the type defined in the basic functions are allocated to the stack memory function. When defining a variable block of code, Java stack is allocated in variable memory space, when exceeding the scope of variables, Java automatically freed memory space allocated for the variable, the memory space can be immediately for other purposes.
  Heap memory used to store objects and arrays created by the new, the memory allocated on the heap, the automatic garbage collector Java virtual machine to manage. After the heap produce an array or object, you can also define a special variable in the stack, the stack so that the value of this variable is equal to the first address of the array or object in the heap memory, stack variable became an array or object reference variables. Reference variable is equivalent to a name from the array or object, since you can access the heap array or object reference variables using the stack in the program.
Assigning Java variables in memory:
  1, class variables (static variables modified): when the program loads the system as it opens up memory on the heap, the heap memory address stored in the stack to facilitate high-speed access. The life cycle of static variables - until the whole "system" shut down.
  2, instance variables: java when you use the new keyword, the system heap is not necessarily contiguous open space assigned to the variable (for example, class instance), then according to scattered heap memory address, through a hashing algorithm conversion is a long string of numbers to characterize the "physical location" variable in the stack. Lifecycle instance variables - when the instance variable references after the loss, will be included in GC (garbage collector) recyclable "list", but not immediately release the heap memory.
  3, local variables: Local variables, a statement by the method, or in a code segment (for example, loop), when it is executed to open the stack memory, when a local variable, but goes out of scope, the memory is released immediately.
Array (Array) and list (ArrayList) What is the difference? When should I use Array instead of ArrayList?
Array can contain primitive types and object types, ArrayList only contains the object type. Array size is fixed, the size of the ArrayList is dynamic.

Published 24 original articles · won praise 0 · Views 421

Guess you like

Origin blog.csdn.net/WillliveWillWork/article/details/103908121
set
set