首先,Integer继承了Number类并且实现了Comparable接口, 因为Number类实现了Serializable接口,所以Integer是可序列化的.实现了Comparable接口则可以排序,并且实现逻辑为从小到大排序.
Integer中最小值最大值分别为0x80000000和0x7fffffff
转(
Integer.MAX_VALUE为2的31次方减一 2 147 483 647 ,Integer.MIN_VALUE为负2的31次方为 2 147 483 648 Integer.max_value = 01111111 111111111111111111111111+1 = 10000000 00000000 00000000 00000000最高位是符号位为1,这个数是负数,负数的源码是补码取反+1,刚好等于Integer.min_value
)
type这个属性和int.class有些不同,因为int.class是虚拟机运行时就加载在虚拟机中的,而type这个属性是Integer类被使用时才加载的int的字节码. 所以在特殊情况下会有不同.
转:(
方法摘要 | |
static int | bitCount(int i) |
byte | byteValue() |
int | compareTo(Integer anotherInteger) |
static Integer | decode(String nm) |
double | doubleValue() |
boolean | equals(Object obj) |
float | floatValue() |
static Integer | getInteger(String nm) |
static Integer | getInteger(String nm, int val) |
static Integer | getInteger(String nm, Integer val) |
int | hashCode() |
static int | highestOneBit(int i) |
int | intValue() |
long | longValue() |
static int | lowestOneBit(int i) |
static int | numberOfLeadingZeros(int i) |
static int | numberOfTrailingZeros(int i) |
static int | parseInt(String s) |
static int | parseInt(String s, int radix) |
static int | reverse(int i) |
static int | reverseBytes(int i) |
static int | rotateLeft(int i, int distance) |
static int | rotateRight(int i, int distance) |
short | shortValue() |
static int | signum(int i) |
static String | toBinaryString(int i) |
static String | toHexString(int i) |
static String | toOctalString(int i) |
String | toString() |
static String | toString(int i) |
static String | toString(int i, int radix) |
static Integer | valueOf(int i) |
static Integer | valueOf(String s) |
static Integer | valueOf(String s, int radix) |
)
Long源码和Integer源码基本相同,所以不再单独列出