It contains the collections framework, legacy collection classes, event model, date and time facilities, internationalization, and miscellaneous utility classes (a string tokenizer, a random-number generator, and a bit array). Some of the Enhanced Collections Framework are described below:



  • Enhanced Collections Framework - The Collections Framework has these new convenience APIs:

    • Added Collections.singletonList and Collections.singletonMap.

      Previously, there was a convenience implementation for singleton Set, but no corresponding implementation for List and Map. Both of these implementations proved desirable in practice.

    • Added Collections.EMPTY_MAP.

      Previously, there were constant convenience implementations for the empty Set and List, but no corresponding implementation for Map.

      The following special-purpose implementation has also been added:

    • Added Map constuctor for WeakHashMap. The Map interface dictates that most Map implementations should have a "copy constructor" that takes a Map argument. WeakHashMap lacked such a constructor in the 1.2 release.




 



Let's take an example of java.util collection.











import java.util.*;

public class SetExample {

  public static void main(String args[])


{

    Set set = new HashSet();

    set.add("Bernadine");

    set.add("Elizabeth");

    set.add("Gene");

    set.add("Elizabeth");

    set.add("Clara");

    System.out.println(set);

    Set sortedSet = new TreeSet(set);

    System.out.println(sortedSet);

  }

}




 











 

                    

Copyright © 2012 VisualBuilder. All rights reserved