1 16 package java.lang; 17 18 21 public final class Byte extends Number implements Comparable { 22 public static final byte MIN_VALUE = (byte) 0x80; 23 public static final byte MAX_VALUE = (byte) 0x7F; 24 25 public static Byte decode(String s) throws NumberFormatException { 26 return new Byte ((byte)__decodeAndValidateLong(s, MIN_VALUE, MAX_VALUE)); 27 } 28 29 public static byte parseByte(String s) throws NumberFormatException { 30 final int baseTen = 10; 31 return parseByte(s, baseTen); 32 } 33 34 public static byte parseByte(String s, int radix) 35 throws NumberFormatException { 36 return (byte)__parseAndValidateLong(s, radix, MIN_VALUE, MAX_VALUE); 37 } 38 39 public static String toString(byte b) { 40 return String.valueOf(b); 41 } 42 43 public static Byte valueOf(String s) throws NumberFormatException { 44 return new Byte (Byte.parseByte(s)); 45 } 46 47 public static Byte valueOf(String s, int radix) throws NumberFormatException { 48 return new Byte (Byte.parseByte(s, radix)); 49 } 50 51 private final transient byte value; 52 53 public Byte(byte value) { 54 this.value = value; 55 } 56 57 public Byte(String s) { 58 value = parseByte(s); 59 } 60 61 public byte byteValue() { 62 return value; 63 } 64 65 public int compareTo(Byte b) { 66 if (value < b.value) { 67 return -1; 68 } else if (value > b.value) { 69 return 1; 70 } else { 71 return 0; 72 } 73 } 74 75 public int compareTo(Object o) { 76 return compareTo((Byte ) o); 77 } 78 79 public double doubleValue() { 80 return value; 81 } 82 83 public boolean equals(Object o) { 84 return (o instanceof Byte ) && (((Byte ) o).value == value); 85 } 86 87 public float floatValue() { 88 return value; 89 } 90 91 public int hashCode() { 92 return value; 93 } 94 95 public int intValue() { 96 return value; 97 } 98 99 public long longValue() { 100 return value; 101 } 102 103 public short shortValue() { 104 return value; 105 } 106 107 public String toString() { 108 return toString(value); 109 } 110 } 111 | Popular Tags |