1. Use your own words to describe what is a set, the importance of a set, and the methods that the set should provide (crud)
2. Read the help of collection to introduce the concept of bags.
3. the concept of set, which introduces the difference between hashset and treeset. the removeall method leads to the template method design pattern (the parent class method completes the business flow, this business flow calls other methods, and other methods are abstract and completed by the subclass ), the Strategy Mode is derived by the treeset (comparator) constructor (tasks with a relatively large size are delegated to a dedicated comparator ). By the way, we introduced "try to use combinations to avoid inheritance" and "Closing principles". They should not only be principles, but should be pursued as design goals.
4. hashset is stored according to some calculation method of hashcode value, instead of directly storing according to the size of hashcode value. For example,
"ABC" ---> 78, "def" ---> 62, "XYZ" ---> the storage order of 65 in hashset is not, 65, 78, thanks to the previous student Cui Jian for asking these questions. Source code Explain to him how many trainees can understand the source code.
Linkedhashset is stored in the inserted sequence. What is the role of the hashcode method of the stored object? Think about it! The hashset Sets compare whether two objects are equal. First, check whether the hashcode method is equal, and then check whether the equals method is equal. New student is inserted into the hashset. Check the size of the hashset, implement the hashcode and equals methods, and then read the size again.
5. hashset explains the generics in j2se 5.0, uses public Boolean equals (student OBJ) to issue the equals method, and explains how to avoid this problem through the @ override annotation of j2se5.0.
6. For Loop enhancement statements in j2se5.0.
7. Student problem: when the <property> element is used to reference a property file in the build. xml file, there is no Chinese comment in the property file. This introduces the native2ascii command. See the help of the property class to connect to the help of native2ascii.
8. The same object can be added multiple times in the vector. Adding an element to the set is equivalent to connecting the set to the target object with a rope.
9. Write the following synthesis Code To enhance the understanding of collections, generics, and for loops:
Hashmap <string, integer> Hm = new hashmap <string, integer> ();
Hm. Put ("zxx", 19 );
Hm. Put ("lis", 18 );
Set <map. Entry <string, integer> MEs = hm. entryset ();
// Map. Entry <string, integer> me; // This cannot be the case!
For (Map. Entry <string, integer> me: MEs)
{
System. Out. println (Me. getkey () + ":" + me. getvalue ());
}
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.