objects in 1.set are not repeated in the order they are loaded . repeat judgment: as long as the two objects equals equal to the line. ( to understand that, not repeating the error, but only one storage time, the output will only output one.) )
Data objects in 2.list are ordered and can be duplicated
1) array read fast change slow
This is implemented in the form of an array, read the time according to the pointer can be read quickly, but change the time to copy the different parts and create a new array, so it is more troublesome.
2) linked fast reading slow
3. Loop out the contents of the collection:
1) Iterator mode iteration: Create an iterator for each object itself, and then use an iterator to determine if there is a next, then output.
2) used for loop form after jdk1.4
for (int aaa:list1) {
System.out.println (AAA);
}
is to list1 the contents of the collection into the AAA, and then output . However, in addition to traversing the output of all the content, there is no other benefits, such as to delete a certain time can not be implemented, see not recommended to use this method.
4. Automatic boxing and unpacking: In the collection, add the object, but jdk1.4 can add the basic number directly after the
Type, but this involves packing and unpacking problems.
1) Boxing: The underlying data type is converted to an object type that is boxed, which is to load an object into the underlying data type.
2) Unpacking: The object is transformed into a basic data type.
5. Generics
1) Why generics are used: the type of the mounted collection is treated as object, thus losing the original actual type. Therefore, after extracting from the set, it needs transformation, low efficiency and easy to make mistakes.
2) Use generics: Define the object types in the collection while defining the collection.
3) Scope of use: the essence of generics is to parameterize data types, not just collections, but also other places. Those classes can be used generics, look at the API documentation, API documentation can be used.
Java collection, generic simple summary