对应关系
基本类型 | 包装类 | 父类 |
---|
byte | Byte | Number |
short | Short | Number |
int | Integer | Number |
long | Long | Number |
float | Float | Number |
double | Double | Number |
char | Character | Object |
boolean | Boolean | Object |
Integer
package com.yuzhenc.common;
public class Test01 {
public static void main(String[] args) {
System.out.println(Integer.MAX_VALUE);
System.out.println(Integer.MIN_VALUE);
System.out.println(Integer.MAX_VALUE+1);
System.out.println(Integer.MIN_VALUE-1);
Integer num1 = new Integer(12);
Integer num2 = new Integer("12");
Integer num4 = 12;
int num5 = new Integer(12);
Integer num6 = new Integer(12);
int num7 = 12;
Integer num8 = 256;
Integer num9 = 256;
Integer num10 = 12;
System.out.println(num1 == num6);
System.out.println(num5 == num7);
System.out.println(num4 == num10);
System.out.println(num8 == num9);
System.out.println(num1.equals(num2));
System.out.println(num1.compareTo(num2));
System.out.println((num1<num2) ? -1 : ((num1==num2) ? 0 : 1));
System.out.println((num1.intValue()<num2.intValue()) ? -1 : ((num1.intValue()==num2.intValue()) ? 0 : 1));
System.out.println(Integer.parseInt("12"));
System.out.println(num1.toString());
}
}