This part contains some tips or personal experience for Java.
- TreeMap.keySet() returns a sorted set which is similar to TreeSet.
- Map.keySet() returns a set view of the keys contained in this map. If you modify this set will modify the keys in the Map. For example, if you use Set.retainAll() function. You can create a new set: Set<T> set = new HashSet<T>(Map.keySet()). TreeSet also works here.
retainAll(Collection c):Retains only the elements in this set that are contained in the specified collection (optional operation). This is exact the intersection of two sets: A ^ B. The return value tells you the original set changed or not. Remember to test original set isEmpty() or not before to use it.
removeAll(Collection c)provides A – B. And
addAll(Collection c)provides A + B.
switchstatement allows for any number of possible execution paths. A
switchworks with the
intprimitive data types. It also works with enumerated types (discussed in Classes and Inheritance) and a few special classes that “wrap” certain primitive types:
Integer(discussed in Simple Data Objects ). (Source)
This parts includes good articles, tutorials and books for Java.
- 5 things you didn’t know about … the Java Collections API Part1 Part2 (Chinese Version 1 2)
- 2009 Java 专区最受欢迎内容 (Chinese)
The Java Tutorials are practical guides for programmers who want to use the Java programming language to create applications. They include hundreds of complete, working examples, and dozens of lessons. Groups of related lessons are organized into “trails”.
- Creating a GUI With JFC/Swing
- The Reflection API
- Lesson: Concurrency