phương pháp tĩnh, bạn thường sẽ sử dụng getClass (). Bạn không cần phải sử dụng lớp hiện tại như là định danh nút, nhưng đó là thực hành thông thường. Phản hồi Một khi bạn tạo ra các nút, nó có sẵn dữ liệu hoặc tải hoặc đọc. | static method you ll usually use getClass . You don t need to use the current class as the node identifier but that s the usual practice. Feedback Once you create the node it s available for either loading or reading data. This example loads the node with various types of items and then gets the keys . These come back as a String which you might not expect if you re used to keys in the collections library. Here they re converted to a List which is used to produce an Iterator for printing the keys and values. Notice the second argument to get . This is the default value which is produced if there isn t any entry for that key value. While iterating through a set of keys you always know there s an entry so using null as the default is safe but normally you ll be fetching a named key as in Feedback Companions 0 In the normal case you ll want to provide a reasonable default value. In fact a typical idiom is seen in the lines int usageCount UsageCount 0 usageCount UsageCount usageCount This way the first time you run the program the UsageCount will be zero but on subsequent invocations it will be nonzero. Feedback When you run you ll see that the UsageCount does indeed increment every time you run the program but where is the data stored There s no local file that appears after the program is run the first time. The Preferences API uses appropriate system resources to accomplish its task and these will vary depending on the OS. In Windows the registry is used since it s already a hierarchy of nodes with key-value pairs . But the whole point is that the information is magically stored for you so that you don t have to worry about how it works from one system to another. Feedback There s more to the preferences API than shown here. Consult the JDK documentation which is fairly understandable for further details. Feedback 684 Thinking in Java Regular expressions To finish this chapter we ll look