Enhance the For Loop
1. The for loop can do things, and most of the enhancement for loops can be done (if you want to obtain the lower mark, you must use a simple for loop)
2. Enhanced for can easily process the traversal of a set, but the standard traversal of a set uses the iterator.
3. It shows its strength in the Collection framework.
Map interface Traversal
Map interface traversal:
1. The first method uses the map. Values () method. First, the value is put in a collection.
2. The second method uses the map. entryset () method (recommended)
3. The third method is map. keyset ().
In fact, there are very few traversal operations on the map interface, and query operations are usually performed on it.
Code operations by traversing values in the map interface
System. Out. println ("========= first method ========= ");
// How to iterate the map content
// The first method uses the map. Values () method. The value is first put in a collection.
Collection <person> collections = map. Values ();
For (person: collections ){
System. Out. println (person );
}
// The second method uses the map. entryset () method (the most recommended method)
System. Out. println ("========= second method ======= ");
// Set <entry <string, person> set = map. entryset ();
For (Entry <string, person> entry: map. entryset ()){
System. Out. println (entry. getvalue ());
}
System. Out. println ("========= third method ======= ");
// Method 3 use map. keyset ()
// Set <string> keyset = map. keyset ();
For (string key: map. keyset ()){
System. Out. println (key );
System. Out. println (Map. Get (key ));
}
Variable parameters
Variable parameters (simple but practical tips)
The appearance of variable parameters facilitates Program Development
Object... ARGs
String... ARGs
Format: (data type... Parameter Name (can be obtained at Will ))
Zookeeper