Array and List in Java

A. Array Array

1. array is stored contiguously in memory, so it's indexing speed is very fast, but the assignment is simple and modify elements
2. When declaring an array, you must also specify the length of the array of arrays is too long, resulting in a waste of memory, and an array of length is too short, it can cause erroneous data overflow.
3. The array can store the same data type (basic type / reference type)

 

II. Collection Collection
1. Only the JAVA stored set of reference data types, basic data types can not be stored. But the collection can store different types of reference types, because the elements of the collection are stored transformed into Object type, and then later referenced collection types require casts, which leads to unsafe type collections, and the type of transformation performance loss
three .List (list) is the interface, inheritance and set (set) with the collection interface, please note, map collection interfaces do not inherit, map provides the mapping key to value. 
Linear is a logical structure, and last remove the outer element, the other element has a unique predecessor and successor data structure.

1. Set List and the difference between:
List features: element has placed the order, the elements may be repeated, Set Features: No element into the sequence, non-resettable element (note: although no element into the sequence, but the elements in the set position HashCode is determined that element, in fact, its location is fixed)


2. List three implementation classes: the Vector ArrayList LinkedList
2.1 is the underlying ArrayList array implementation.
2.2 LinkedList is a doubly linked list implementation, suitable for frequent additions and deletions operation, but the query and modify the efficiency did not ArrayList, fast Vector.
2.3 Vector and ArrayList similar, but also an array to achieve, but he is synchronized, thread-safe, there is no problem of concurrent produced, but less efficient than ArrayList.

1. array is stored contiguously in memory, so it's indexing speed is very fast, but the assignment is simple and modify elements
2. When declaring an array, you must also specify the length of the array of arrays is too long, resulting in a waste of memory, and an array of length is too short, it can cause erroneous data overflow.
3. The array can store the same data type (basic type / reference type)

 

II. Collection Collection
1. Only the JAVA stored set of reference data types, basic data types can not be stored. But the collection can store different types of reference types, because the elements of the collection are stored transformed into Object type, and then later referenced collection types require casts, which leads to unsafe type collections, and the type of transformation performance loss
three .List (list) is the interface, inheritance and set (set) with the collection interface, please note, map collection interfaces do not inherit, map provides the mapping key to value. 
Linear is a logical structure, and last remove the outer element, the other element has a unique predecessor and successor data structure.

1. Set List and the difference between:
List features: element has placed the order, the elements may be repeated, Set Features: No element into the sequence, non-resettable element (note: although no element into the sequence, but the elements in the set position HashCode is determined that element, in fact, its location is fixed)


2. List three implementation classes: the Vector ArrayList LinkedList
2.1 is the underlying ArrayList array implementation.
2.2 LinkedList is a doubly linked list implementation, suitable for frequent additions and deletions operation, but the query and modify the efficiency did not ArrayList, fast Vector.
2.3 Vector and ArrayList similar, but also an array to achieve, but he is synchronized, thread-safe, there is no problem of concurrent produced, but less efficient than ArrayList.

Guess you like

Origin www.cnblogs.com/jeasonit/p/11880345.html