import java.util.*;
public class TestMap {
public static void main(String args[]) {
Map m1 = new HashMap();
Map m2 = new TreeMap();
//m1.put("one",new Integer(1));
m1.put("one", 1);
//m1.put("two",new Integer(2));
m1.put("two", 2);
//m1.put("three",new Integer(3));
m1.put("three", 3);
//m2.put("A",new Integer(1));
m2.put("A", 1);
//m2.put("B",new Integer(2));
m2.put("B", 2);
System.out.println(m1.size());
System.out.println(m1.containsKey("one"));
System.out.println
//(m2.containsValue(new Integer(1)));
(m2.containsValue(1));
if(m1.containsKey("two")) {
//int i = ((Integer)m1.get("two")).intValue();
int i = (Integer)m1.get("two");
System.out.println(i);
}
Map m3 = new HashMap(m1);
m3.putAll(m2);
System.out.println(m3);
}
}我在自学马士兵老师的视频教程,这段代码是他给的例子中的,我先自己写,编译的时候出现28个错误,然后我找到了他的源代码,编译还是28个错误,这28个错误基本都是can not find symbol 这种错误,求解到底是怎么回事,看视频老师在自己的机器上明明编译成功了
public class TestMap {
public static void main(String args[]) {
Map m1 = new HashMap();
Map m2 = new TreeMap();
//m1.put("one",new Integer(1));
m1.put("one", 1);
//m1.put("two",new Integer(2));
m1.put("two", 2);
//m1.put("three",new Integer(3));
m1.put("three", 3);
//m2.put("A",new Integer(1));
m2.put("A", 1);
//m2.put("B",new Integer(2));
m2.put("B", 2);
System.out.println(m1.size());
System.out.println(m1.containsKey("one"));
System.out.println
//(m2.containsValue(new Integer(1)));
(m2.containsValue(1));
if(m1.containsKey("two")) {
//int i = ((Integer)m1.get("two")).intValue();
int i = (Integer)m1.get("two");
System.out.println(i);
}
Map m3 = new HashMap(m1);
m3.putAll(m2);
System.out.println(m3);
}
}我在自学马士兵老师的视频教程,这段代码是他给的例子中的,我先自己写,编译的时候出现28个错误,然后我找到了他的源代码,编译还是28个错误,这28个错误基本都是can not find symbol 这种错误,求解到底是怎么回事,看视频老师在自己的机器上明明编译成功了
所以只要你的jdk是1.5及以上版本应该不会有问题。
可能你用editplus,环境变量中的JDK版本太低。