字符常量池和自动包装
package p1
;
public class I {
public static void main(String
[] args
) {
char c1
= new Character('a');
char c2
= new Character('a');
System
.out
.println(c1
== c2
);
Character c3
= new Character('a');
Character c4
= new Character('a');
System
.out
.println(c3
== c4
);
Character c5
= 'a';
Character c6
= 'a';
System
.out
.println(c5
== c6
);
}
}
运行结果:
true
false
true
转载请注明原文地址:https://tech.qufami.com/read-8115.html