4 * Minimal Integer implementation that supports converting an int to a String.
8 public final class Integer {
10 * The smallest value of type <code>int</code>. The constant
11 * value of this field is <tt>-2147483648</tt>.
13 public static final int MIN_VALUE = 0x80000000;
16 * The largest value of type <code>int</code>. The constant
17 * value of this field is <tt>2147483647</tt>.
19 public static final int MAX_VALUE = 0x7fffffff;
22 * The value of the Integer.
29 * Constructs a newly allocated <code>Integer</code> object that
30 * represents the primitive <code>int</code> argument.
32 * @param value the value to be represented by the <code>Integer</code>.
34 public Integer(int value) {
38 static char buf [] = new char [12] ;
41 * Returns a new String object representing the specified integer. The
42 * argument is converted to signed decimal representation and returned
43 * as a string, exactly as if the argument and radix <tt>10</tt> were
44 * given as arguments to the toString(int, int) method.
46 * @param i an integer to be converted.
47 * @return a string representation of the argument in base 10.
49 public static synchronized String toString(int i) {
50 int q, r, charPos = 12;
53 if (i == Integer.MIN_VALUE) return "-2147483648";
63 buf [--charPos] = (char) ((int) '0' + r) ;
69 buf [--charPos] = sign ;
72 return new String ( buf, charPos, 12 - charPos) ;
76 * Returns a String object representing this Integer's value. The
77 * value is converted to signed decimal representation and returned
80 * @return a string representation of the value of this object in
83 public String toString() {
84 return toString(value);