代码如下,在eclipse中普通下提示红色波浪线。
package test20160304;
public class WeakHashMap {
public static void main(String[] args) {
// TODO Auto-generated method stub
WeakHashMap w = new WeakHashMap();
w.put(new String("ab"), new String("cd"));
}
}
详细的错误提示是:
The method put(String, String) is undefined for the type WeakHashMap
使用命令行编译提示:
找不到符号put。
手动添加import语句后则提示:
错误:已在该编译单元中定义WeakHashMap。
eclipse中提示:
The import java.util.WeakHashMap conflicts with a type defined in the same file
谷歌后发现自己是第二次犯这种错误了。。。。因为自己用来测试的类的名字和WeakHashMap一样。。。