1. Differences between the various maps
HashMap: does not save its elements in any apparent order (same as HashSet)
TreeMap: Save key in ascending order of comparison (same as TreeSet)
Linkedhashmap: Save key in Insert order (same as Linkedhashset)
2.ListIterator is a more powerful iterator subtype, iterator can only move forward, but Listiterator can move in both directions
public class Listiteration {public static void main (string[] args) {list<pet> pets = Pets.arraylist (8); Listiterator<pet> it = Pets.listiterator ();//Forwards:while (It.hasnext ()) {System.out.print (It.next () + "," + it . Nextindex () + "," + it.previousindex () + ";"); Backwards:while (It.hasprevious ()) {System.out.print (It.previous (). ID () + "");}}
3. The elements in TreeSet are sorted by default according to the dictionary ascending, and of course we can pass in a comparer ourselves to customize the sort.
public class Uniquewordsalphabetic {public static void main (string[] args) {set<string> words = new Treeset<strin G> (String.case_insensitive_order), Words.add ("a"), Words.add ("C"); Words.add ("B"); SYSTEM.OUT.PRINTLN (words);}}
Think in Java (eight): Holding object