Chapter 1 Overview of common Java Collection classes and java Overview
1. The most common collection classes in Java
- Collection Interface
- List interface (repeated elements are allowed): ArrayList, rule List, Vector, and Stack
- Set interface (repeated elements are not allowed,Can be used for deduplication): HashSet, TreeSet
- Map Interface
- HashMap
- TreeMap (sort by key)
2. Seven Points for Collection
- Create Collection: the constructor. You can understand what the Collection implementation class has done in the constructor method.
- Add an object to the Collection: add (E) Method -->The implementation method of the Class determines the performance of this method.
- Delete objects in the Collection: remove (E) Method -->The implementation method of the Class determines the performance of this method.
- Obtain a single object in the Collection: get (int index) Method -->The implementation method of the Class determines the performance of this method.
- Traverse objects in the Collection: iterator. In practice, the enhanced for loop is more commonly used for traversing.
- Determine whether the object exists in the Collection: contain (E) -->The implementation method of the Class determines the performance of this method.
- Object sorting in Collection: mainly depends on the Sorting Algorithm adopted
The Collection analysis will be based on the above points.
3. Seven Points for Map
- Map creation: the constructor, master the implementation class of Map in the constructor method.
- Add a key-value pair to Map: put (Object key, Object value) Method
- Delete objects in Map: The remove (Object key) Method
- Get a single Object in Map: get (Object key) Method
- Determine whether an Object exists in Map: containsKey (Object key)
- Traverse objects in Map: keySet () and iterator
- Sorting of objects in Map: mainly depends on the Sorting Algorithm adopted
The Analysis of Map is based on the above points.
Note:
- Many of the content in this series will refer to distributed Java applications: basics and practices.Lin HaoWritten.
- The content of this series is based on JDK1.6.45. We recommend that you associate the source code with eclipse.