Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6324422

(coll) Use generics in code examples in Hashtable.java

XMLWordPrintable

      A DESCRIPTION OF THE PROBLEM :
      Classes of the collections API have been turned to generic classes, but the class documentation is not updated.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      That should now become

       This example creates a hashtable of numbers. It uses the names of the numbers as keys:

           Hashtable<String, Integer> numbers = new Hashtable<String, Integer>();
           numbers.put("one", new Integer(1));
           numbers.put("two", new Integer(2));
           numbers.put("three", new Integer(3));
       
      Or, with automatic wrapping, even new Integer(1) can be replaced by 1.
      ACTUAL -
      E.g. in Hashtable, it says

       This example creates a hashtable of numbers. It uses the names of the numbers as keys:

           Hashtable numbers = new Hashtable();
           numbers.put("one", new Integer(1));
           numbers.put("two", new Integer(2));
           numbers.put("three", new Integer(3));
       

      URL OF FAULTY DOCUMENTATION :
      http://java.sun.com/j2se/1.5.0/docs/api/java/util/Hashtable.html (amongst others)

            martin Martin Buchholz
            jssunw Jitender S (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: