package DemoTest; public class IntegerTest { public static void main(String[] args) { Integer i1 = new Integer("123"); System.out.println(i1); Integer i2 = new Integer(123); System.out.println(i2); System.out.println(i1==i2); // false System.out.println(i1.equals(i2)); // true Integer i1Integer = 97; Integer i2Integer = 97; System.out.println(i1Integer==i2Integer); // true,在byte -128~127范围不会创建新对象 Integer i3Integer = 197; Integer i4Integer = 197; System.out.println(i3Integer==i4Integer); // false String s3 = "123"; Integer i3 = new Integer(s3); System.out.println(i3); int i4 = i3.valueOf(i3); System.out.println(i4); int i5 = Integer.parseInt(s3); System.out.println(i5); } }