2007-07-19 21:18:25 -06:00
|
|
|
package java.lang;
|
|
|
|
|
2007-09-26 08:44:56 -06:00
|
|
|
public final class Integer extends Number implements Comparable<Integer> {
|
2007-07-28 10:55:24 -06:00
|
|
|
public static final Class TYPE = Class.forCanonicalName("I");
|
2007-07-26 20:39:53 -06:00
|
|
|
|
2007-07-29 17:32:23 -06:00
|
|
|
public static final int MIN_VALUE = 0x80000000;
|
|
|
|
public static final int MAX_VALUE = 0x7FFFFFFF;
|
|
|
|
|
2007-07-19 21:18:25 -06:00
|
|
|
private final int value;
|
|
|
|
|
|
|
|
public Integer(int value) {
|
|
|
|
this.value = value;
|
|
|
|
}
|
|
|
|
|
2007-09-13 20:19:44 -06:00
|
|
|
public Integer(String s) {
|
|
|
|
this.value = parseInt(s);
|
|
|
|
}
|
|
|
|
|
2007-08-12 18:50:25 -06:00
|
|
|
public static Integer valueOf(int value) {
|
|
|
|
return new Integer(value);
|
|
|
|
}
|
|
|
|
|
2007-07-29 17:32:23 -06:00
|
|
|
public boolean equals(Object o) {
|
|
|
|
return o instanceof Integer && ((Integer) o).value == value;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int hashCode() {
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
2007-09-26 08:44:56 -06:00
|
|
|
public int compareTo(Integer other) {
|
|
|
|
return value - other.value;
|
|
|
|
}
|
|
|
|
|
2007-07-29 17:32:23 -06:00
|
|
|
public String toString() {
|
|
|
|
return toString(value);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static String toString(int v, int radix) {
|
|
|
|
return Long.toString(v, radix);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static String toString(int v) {
|
|
|
|
return toString(v, 10);
|
|
|
|
}
|
|
|
|
|
2007-08-30 17:31:32 -06:00
|
|
|
public static String toHexString(int v) {
|
2007-12-26 12:17:52 -07:00
|
|
|
return Long.toString(((long) v) & 0xFFFFFFFFL, 16);
|
2007-08-30 17:31:32 -06:00
|
|
|
}
|
|
|
|
|
2007-07-21 11:50:26 -06:00
|
|
|
public byte byteValue() {
|
|
|
|
return (byte) value;
|
|
|
|
}
|
|
|
|
|
|
|
|
public short shortValue() {
|
|
|
|
return (short) value;
|
|
|
|
}
|
|
|
|
|
2007-07-19 21:18:25 -06:00
|
|
|
public int intValue() {
|
|
|
|
return value;
|
|
|
|
}
|
2007-07-21 11:50:26 -06:00
|
|
|
|
|
|
|
public long longValue() {
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
public float floatValue() {
|
|
|
|
return (float) value;
|
|
|
|
}
|
|
|
|
|
|
|
|
public double doubleValue() {
|
|
|
|
return (double) value;
|
|
|
|
}
|
2007-07-27 17:56:19 -06:00
|
|
|
|
2007-08-02 19:49:32 -06:00
|
|
|
public static int parseInt(String s) {
|
|
|
|
return parseInt(s, 10);
|
|
|
|
}
|
|
|
|
|
2007-07-27 17:56:19 -06:00
|
|
|
public static int parseInt(String s, int radix) {
|
|
|
|
return (int) Long.parseLong(s, radix);
|
|
|
|
}
|
2007-07-19 21:18:25 -06:00
|
|
|
}
|