d:\java>javac TestMap.java
Note: TestMap.java uses unchecked or unsafe operations.
Note: Recomile with -Xlint:unchecked for details.

解决方案 »

  1.   

    @SuppressWarnings({"unchecked", "rawtypes"})在使用map的方法上面加上上面一句话,或者在使用map是,指定键值的类型,即可解决问题。比如:    @SuppressWarnings({"unchecked", "rawtypes"})
        public void test()
        {
            Map m = new HashMap();
            m.put(1, "ss");
            System.out.println(m.get(1));
        }改成:    public void test()
        {
            Map<Integer, String> m = new HashMap<Integer, String>();
            m.put(1, "ss");
            System.out.println(m.get(1));
        }