<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">import java.util.HashMap;
import java.util.Map;

class Generics {

   public static void main(String[] args) {
      test1();
      test2();
   }

   // old style, pre-Java 5
   // this line will now give a 'raw type' warning in Eclipse
   static Map h1 = new HashMap();

   static void test1() {
      h1.put("one", new Integer(2110));
      Integer s = (Integer)h1.get("one");
      System.out.println(s);
   }

   // new style
   static Map&lt;String, Integer&gt; h2 = new HashMap&lt;String, Integer&gt;();

   static void test2() {
      h2.put("two", 2110); // int is automatically 'boxed' to make an Integer
      int s = h2.get("two"); // and 'unboxed' when you extract it
      System.out.println(s);
   }
}
</pre></body></html>