FileDocCategorySizeDatePackage
Byte.javaAPI DocJ2ME CLDC 1.12922Wed Feb 05 15:55:58 GMT 2003java.lang

Byte

public final class Byte extends Object
The Byte class is the standard wrapper for byte values.
author
Nakul Saraiya
version
12/17/01 (CLDC 1.1)
since
JDK1.1, CLDC 1.0

Fields Summary
public static final byte
MIN_VALUE
The minimum value a Byte can have.
public static final byte
MAX_VALUE
The maximum value a Byte can have.
private byte
value
The value of the Byte.
Constructors Summary
public Byte(byte value)
Constructs a Byte object initialized to the specified byte value.

param
value the initial value of the Byte

        this.value = value;
    
Methods Summary
public bytebyteValue()
Returns the value of this Byte as a byte.

return
the value of this Byte as a byte.

        return value;
    
public booleanequals(java.lang.Object obj)
Compares this object to the specified object.

param
obj the object to compare with
return
true if the objects are the same; false otherwise.

        if (obj instanceof Byte) {
            return value == ((Byte)obj).byteValue();
        }
        return false;
    
public inthashCode()
Returns a hashcode for this Byte.

        return (int)value;
    
public static byteparseByte(java.lang.String s)
Assuming the specified String represents a byte, returns that byte's value. Throws an exception if the String cannot be parsed as a byte. The radix is assumed to be 10.

param
s the String containing the byte
return
the parsed value of the byte
exception
NumberFormatException If the string does not contain a parsable byte.


                                                                                                 
           
        return parseByte(s, 10);
    
public static byteparseByte(java.lang.String s, int radix)
Assuming the specified String represents a byte, returns that byte's value. Throws an exception if the String cannot be parsed as a byte.

param
s the String containing the byte
param
radix the radix to be used
return
the parsed value of the byte
exception
NumberFormatException If the String does not contain a parsable byte.

        int i = Integer.parseInt(s, radix);
        if (i < MIN_VALUE || i > MAX_VALUE)
            throw new NumberFormatException();
        return (byte)i;
    
public java.lang.StringtoString()
Returns a String object representing this Byte's value.

      return String.valueOf((int)value);