我有我的機器上工作好代碼:的方法代替(字符串,ArrayList的<>)是未定義的類型HashMap的
ArrayList<Posting> postings = invertedLists.get(key);
//---- Apply some changes on postings -----
invertedLists.replace(key, postings);
當我的朋友克隆它給了她這個錯誤代碼:
The method replace(String, ArrayList<Posting>) is undefined for the type HashMap<String,ArrayList<Posting>>
注:invertedLists是HashMap<String,ArrayList<Posting>>
我們在我的項目檢查;我正在使用JavaSE-1.6,她使用JavaSE-1.7。
什麼會導致此問題?
請給出一個簡短的*完整*程序來演示問題。 (代碼爲我編譯。) –
我*懷疑*您實際上使用Java 8,因爲'replace'方法被引入然後... –
這可能有所幫助 - http://www.buggybread.com/2012 /11/error-method-contains-methodname.html –