Java常量池

tech2022-12-16  101

字符常量池和自动包装

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); // 'a'是字符常量 Character c5 = 'a'; Character c6 = 'a'; System.out.println(c5 == c6); } }

运行结果:

true false true
最新回复(0)