Team LiB
Previous Section Next Section

Bytejava.lang

Java 1.1serializable comparable

This class provides an immutable object wrapper around the byte primitive type. It defines useful constants for the minimum and maximum values that can be stored by the byte type and a Class object constant that represents the byte type. It also provides various methods for converting Byte values to and from strings and other numeric types.

Most of the static methods of this class can convert a String to a Byte object or a byte value: the four parseByte( ) and valueOf( ) methods parse a number from the specified string using an optionally specified radix and return it in one of these two forms. The decode( ) method parses a byte specified in base 10, base 8, or base 16 and returns it as a Byte. If the string begins with "0x" or "#", it is interpreted as a hexadecimal number. If it begins with "0", it is interpreted as an octal number. Otherwise, it is interpreted as a decimal number.

Note that this class has two toString( ) methods. One is static and converts a byte primitive value to a string; the other is the usual toString( ) method that converts a Byte object to a string. Most of the remaining methods convert a Byte to various primitive numeric types.

Figure 10-8. java.lang.Byte


public final class Byte extends Number implements Comparable<Byte> {
// Public Constructors
     public Byte(byte value);  
     public Byte(String s) throws NumberFormatException;  
// Public Constants
     public static final byte MAX_VALUE;   =127
     public static final byte MIN_VALUE;   =-128
5.0  public static final int SIZE;     =8
     public static final Class<Byte> TYPE;  
// Public Class Methods
     public static Byte decode(String nm) throws NumberFormatException;  
     public static byte parseByte(String s) throws NumberFormatException;  
     public static byte parseByte(String s, int radix) throws NumberFormatException;  
     public static String toString(byte b);  
     public static Byte valueOf(String s) throws NumberFormatException;  
5.0  public static Byte valueOf(byte b);  
     public static Byte valueOf(String s, int radix) throws NumberFormatException;  
// Methods Implementing Comparable
1.2  public int compareTo(Byte anotherByte);  
// Public Methods Overriding Number
     public byte byteValue( );  
     public double doubleValue( );  
     public float floatValue( );  yu
     public int intValue( );  
     public long longValue( );  
     public short shortValue( );  
// Public Methods Overriding Object
     public boolean equals(Object obj);  
     public int hashCode( );  
     public String toString( );  
}

    Team LiB
    Previous Section Next Section