Name

Byte

Synopsis

Byte provides an object wrapper for a Java byte primitive value. The constructor initializes the wrapper with a byte value, after which the object becomes immutable. The value associated with a Byte object can be retrieved using the byteValue() method.

The static parseByte() converts a numeric value held in a string into a primitive byte. The single-argument variant of this method assumes that the string is encoded in base 10; the two-argument variant can be used to specify a different number base if necessary. A NumberFormatException is thrown if the string does not represent a valid number in the given number base.

The static variables Byte.MIN_VALUE and Byte.MAX_VALUE are byte (not Byte) values that represent the smallest and largest values, respectively, that can be held in a byte primitive.

Note that this class is derived from Object and not Number, as the CLDC does not provide a Number class as the J2SE does.

public final class Byte {  
// Public Constructors
   public Byte( byte value);    
// Public Constants
   public static final byte MAX_VALUE;                           // =127
   public static final byte MIN_VALUE;                           // =-128
                    
// Public Class Methods
   public static byte parseByte(
        String s) throws NumberFormatException;  
   public static byte parseByte(String s, 
        int radix) throws NumberFormatException;    
// Public Instance Methods
   public byte byteValue();    
// Public Methods Overriding Object
   public boolean equals( Object obj);  
   public int hashCode();  
   public String toString();  
}

Get J2ME in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.