我編程以下到Eclipse中,但程序不斷給我的錯誤:The method put(String, String) is undefined for the type HashMap.
據我所知,put()
是正確的方法來使用輸入值到一個HashMap
。任何人都可以幫我調試這個問題嗎?HashMap「方法put()未定義類型HashMap」
import java.util.HashMap;
public class MapTester
{
public static void main(String[] args)
{
HashMap <String, String>hm = new HashMap <String, String>();
hm.put("type", "56.09");
hm.put("call", "PHONE");
hm.put("what", "PHONE");
System.out.println(hm.toString());
}
}
謝謝。
對我而言,它完美無缺。這是你的整個代碼? – 2011-12-22 04:19:50
我編譯並執行它沒有任何問題。它打印出'{call = PHONE,what = PHONE,type = 56.09}'。 *使用JRE6 * – shinkou 2011-12-22 04:22:45
進行測試檢查您的java庫是否可能已損壞。更好地重新安裝你的系統jre – Ashish 2011-12-22 04:22:54