早教吧作业答案频道 -->其他-->
Scjp题目Question174ClicktheExhibitbutton.1.importjava.util.*;2.classKeyMaster{3.publicinti;4.publicKeyMaster(inti){this.i=i;}5.publicbooleanequals(Objecto){returni==((KeyMaster)o).i;}6.publicinthashCode(){returni;
题目详情
Scjp题目
Question 174
Click the Exhibit button.
1.import java.util.*;
2.class KeyMaster {
3.public int i;
4.public KeyMaster(int i) { this.i = i; }
5.public boolean equals(Object o) { return i == ((KeyMaster)o).i; }
6.public int hashCode() { return i; }
7.}
8.public class MapIt {
9.public static void main(String[] args) {
10.Set set = new HashSet();
11.KeyMaster k1 = new KeyMaster(1);
12.KeyMaster k2 = new KeyMaster(2);
13.set.add(k1); set.add(k1);
14.set.add(k2); set.add(k2);
15.System.out.print(set.size() + °:±
16.k2.i = 1;
17.System.out.print(set.size() + °:±
18.set.remove(k1);
19.System.out.print(set.size() + °:±
20.set.remove(k2);
21.System.out.print(set.size());
22.}
23.}
What is the result?
A.4:4:2:2
B.4:4:3:2
C.2:2:1:0
D.2:2:0:0
E.2:1:0:0
F.2:2:1:1
G.4:3:2:1
Answer:F
为什么不选c呢?
Question 174
Click the Exhibit button.
1.import java.util.*;
2.class KeyMaster {
3.public int i;
4.public KeyMaster(int i) { this.i = i; }
5.public boolean equals(Object o) { return i == ((KeyMaster)o).i; }
6.public int hashCode() { return i; }
7.}
8.public class MapIt {
9.public static void main(String[] args) {
10.Set set = new HashSet();
11.KeyMaster k1 = new KeyMaster(1);
12.KeyMaster k2 = new KeyMaster(2);
13.set.add(k1); set.add(k1);
14.set.add(k2); set.add(k2);
15.System.out.print(set.size() + °:±
16.k2.i = 1;
17.System.out.print(set.size() + °:±
18.set.remove(k1);
19.System.out.print(set.size() + °:±
20.set.remove(k2);
21.System.out.print(set.size());
22.}
23.}
What is the result?
A.4:4:2:2
B.4:4:3:2
C.2:2:1:0
D.2:2:0:0
E.2:1:0:0
F.2:2:1:1
G.4:3:2:1
Answer:F
为什么不选c呢?
▼优质解答
答案和解析
因为现在的k2和加入进去的k2不是同一个,所以你根本无法去掉原来那个.
看了Scjp题目Question1...的网友还看了以下:
帮求下 (e^x^3-1-2x^3)/x^3,X->0的极限. 2020-05-16 …
limx->0(e^x+e^2+e^3)/3lim(x~0)((e^x+e^2x+e^3x)/3) 2020-05-17 …
某宗地(丘)有5个界址点,其坐标分别为A(5,1)B(6,1)C(4,4)D(2,2)E(3,1) 2020-05-22 …
e^(2πi*(1/6))=(e^2πi)^(1/6)=1^(1/6)=1e^(2πi*(1/6) 2020-06-12 …
已知△ABC三边BC,CA,AB的中点分别是D(1,-4),E(3,1),F(-2,4),求△AB 2020-06-15 …
求下面函数的解释,看不懂function A = fun(W)[m,n] = size(W); e 2020-06-27 …
lim(x->0)[(e^x^3-1-e^3)/(sin^6)2x]请尽量详细些.题目抄错了不好意 2020-07-10 …
Limx趋向于0tanx-sinx/根号下2+x^2乘以(e^x^3-1)为什么等于1/2根号Li 2020-07-15 …
limx→0sin^62x分之e^x^3-1-X^3sin^62x 2020-07-22 …
Scjp题目Question174ClicktheExhibitbutton.1.importjav 2021-01-21 …