Java Integer 常量池
阿新 • • 發佈:2019-02-08
public class IntegerClassExampleOne { public static void main(String[] javalatte) { Integer i = new Integer(555); Integer j = new Integer(555); if(i==j){ System.out.println("i==j is equal"); }else { System.out.println("i==j is not equal"); } } } public class IntegerClassExampleTwo { public static void main(String[] javalatte) { Integer i = 500; Integer j = new Integer(500); if(i==j){ System.out.println("i==j is equal"); }else { System.out.println("i==j is not equal"); } } } public class IntegerClassExampleThree { public static void main(String[] javalatte) { Integer i = 128; Integer j = 128; if(i==j){ System.out.println("i==j is equal"); }else { System.out.println("i==j is not equal"); } } } public class IntegerClassExampleFour { public static void main(String[] javalatte) { Integer i = 127; Integer j = 127; if(i==j){ System.out.println("i==j is equal"); }else { System.out.println("i==j is not equal"); } } }