public class test22 { public static void main(String[] args){ int num=5; Integer obj1=new Integer(num); System.out.println("obj1的值为"+obj1); Integer obj2=100; System.out.println("obj2的值为"+obj2); Integer obj3=new Integer("-789"); System.out.println("obj3的值为"+obj3); System.out.println(Integer.BYTES); System.out.println(Integer.MAX_VALUE); System.out.println(Integer.MIN_VALUE); System.out.println(Integer.SIZE); //比较大小 System.out.println(obj2.compareTo(100)); System.out.println(obj2.compareTo(102)); System.out.println(obj2.compareTo(10)); //返回值类型 int num1=obj2.intValue(); System.out.println(num1); //将一个字符串转换为int数据返回 int str1=Integer.parseInt("125"); System.out.println(str1+12); //表示1110在二进制的时候十进制是多少 int str2=Integer.parseInt("1110",2); System.out.println(str2); //valueof方法获取一个integer实例 Integer obj4=Integer.valueOf(500); System.out.println(obj4.intValue()); System.out.println(Integer.valueOf("500").intValue()); System.out.println(Integer.valueOf("1110",2).intValue()); //转换为二进制,八进制,十六进制 System.out.println("15的二进制为"+Integer.toBinaryString(15)); System.out.println("15的二进制为"+Integer.toOctalString(15)); System.out.println("15的二进制为"+Integer.toHexString(15)); } }