-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTest.java
More file actions
45 lines (40 loc) · 989 Bytes
/
Test.java
File metadata and controls
45 lines (40 loc) · 989 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
public class Test {
public static void main(String[] args) {
userful[] userfuls={
new userful(),
new moreUseful()
};
//((moreUseful)userfuls[1]).c();//运行时类型识别
//((moreUseful)userfuls[0]).c();
Map<Integer,Integer> map=new HashMap<Integer,Integer>();
//允许值为null
map.put(1, 1);
map.put(2,null);
map.put(null, 3);
Map<Integer,Integer> map1=new HashMap<Integer,Integer>();
//允许值为null
map1.put(1, 1);
map1.put(2,null);
map1.put(null, 3);
Set<Entry<Integer,Integer>> set=map1.entrySet();
for(Entry<Integer,Integer> entry:set){
System.out.println(entry);
}
//比较里面的键值
System.out.println("map equals map1:"+map.equals(map1));
}
}
class userful{
public void a(){}
public void b(){}
}
class moreUseful extends userful{
public void a(){}
public void b(){}
public void c(){}
}