2014-09-26 73 views
-5

我有以下代碼:不支持泛型?

 Map<String, String> prefMap = new HashMap<String, String>(); 
     prefMap.put("ns2", "http://service.fr/myservice1"); 
     prefMap.put("ns3", "http://service.fr/myservice2"); 

當我編譯它,我得到的錯誤:

generics are not supported in -source 1.3 
+9

泛型在Java 5中 – rgettman 2014-09-26 21:21:11

+0

介紹您是如何編制的?將編譯器合規性級別更改爲至少1.5。 – Joffrey 2014-09-26 21:22:03

+5

我的意思是,它不像編譯器沒有告訴你到底是什麼問題。 – vanza 2014-09-26 21:23:03

回答

2

你看上去編譯如Java 3,不支持泛型。

如果您使用命令行,請至少使用-source 1.5

如果你正在使用Eclipse編譯,你可以在設置中更改符合級別至少爲1.5:

Window > Preferences and then Java > Compiler > "Compiler compliance level"