Set set, List, Set set list
Collection System: Collection and Map Interfaces
Objects of different storage quantities cannot store basic data types. For example, basic data types are automatically packed.
========================================================== ================
Sub-interfaces of Collection: Set interface and List Interface
Implementation classes of the Set interface: HashSet, javashashset, and TreeSet
Implementation classes of the List interface: ArrayList, sorted List, and Vector
========================================================== ======
Implementation classes of the Map interface: HashMap, TreeMap, and Hashtable
========================================================== ========
Features:
Collection: indicates the set of objects that are not stored in the order of addition. The elements in the set can be repeated, that is, the "unordered and repeatable" set.
Set: an unordered and non-repeating Set of elements-similar to a high school "Set"
List: an ordered and repeated set of elements --- "dynamic" Array
Map: a set of key-value pairs with Mappings
========================================================== ==========
1. Before Java 5, the Java set will lose the Data Types of all objects in the container and treat all objects as objects. After the generic type is added to Java 5, the Java Collection can remember the Data Type of objects in the container.
2. A foreach loop is also called an enhanced for loop.
For (Object obj: collection ){
System. out. println (obj); // Object: Element type to be traversed; obj: name of the element after traversal; collection: collection Object to be traversed
}
1 @ Test 2 public void test5 () {3 String [] str = new String [5]; 4 for (String myStr: str) {5 myStr = "xiaobing "; 6 System. out. println (myStr); 7} 8 for (int I = 0; I <str. length; I ++) {9 System. out. println (str [I]); 10} 11} 12 13 =================================14 results: 15 xiaobing16 xiaobing17 xiaobing18 xiaobing19 xiaobing20 null21 null22 null23 null24 null