public final class Byte

  1. Object
  2. Number
  3. Byte

ImplementsComparable<Byte>

The Byte class is the standard wrapper for byte values. Since: JDK1.1, CLDC 1.0

Fields

public static final Class<Byte> TYPE
public static final int SIZE = 8
public static final byte MAX_VALUE = 127The maximum value a Byte can have.
public static final byte MIN_VALUE = -128The minimum value a Byte can have.

Constructors

public Byte(byte value)Constructs a Byte object initialized to the specified byte value.

Methods

public byte byteValue()Returns the value of this Byte as a byte.
public boolean equals(Object obj)Compares this object to the specified object.
public int hashCode()Returns a hashcode for this Byte.
public static byte parseByte(String s) throws NumberFormatExceptionAssuming the specified String represents a byte, returns that byte’s value.
public static byte parseByte(String s, int radix) throws NumberFormatExceptionAssuming the specified String represents a byte, returns that byte’s value.
public String toString()Returns a String object representing this Byte’s value.
public static Byte valueOf(byte i)Returns the object instance of i
public int intValue()
public long longValue()
public float floatValue()
public double doubleValue()
public int compare(byte b1, byte b2)
public int compareTo(Byte b)Compares this object to the specified object to determine their relative order.

Inherited methods

Field details

TYPE

public static final Class<Byte> TYPE

SIZE

public static final int SIZE = 8

MAX_VALUE

public static final byte MAX_VALUE = 127
The maximum value a Byte can have. See Also:Constant Field Values

MIN_VALUE

public static final byte MIN_VALUE = -128
The minimum value a Byte can have. See Also:Constant Field Values

Constructor details

Byte

public Byte(byte value)
Constructs a Byte object initialized to the specified byte value. value - the initial value of the Byte

Method details

byteValue

public byte byteValue()
Returns the value of this Byte as a byte.

equals

public boolean equals(Object obj)
Compares this object to the specified object.

hashCode

public int hashCode()
Returns a hashcode for this Byte.

parseByte

public static byte parseByte(String s) throws NumberFormatException
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.

parseByte

public static byte parseByte(String s, int radix) throws NumberFormatException
Assuming the specified String represents a byte, returns that byte’s value. Throws an exception if the String cannot be parsed as a byte.

toString

public String toString()
Returns a String object representing this Byte’s value.

valueOf

public static Byte valueOf(byte i)
Returns the object instance of i

Parameters

i byte
the primitive

Returns

object instance

intValue

public int intValue()

longValue

public long longValue()

floatValue

public float floatValue()

doubleValue

public double doubleValue()

compare

public int compare(byte b1, byte b2)

compareTo

public int compareTo(Byte b)
Compares this object to the specified object to determine their relative order.

Parameters

b Byte
the object to compare to this instance.

Returns

a negative integer if this instance is less than another; a positive integer if this instance is greater than another; 0 if this instance has the same order as another.

Throws

ClassCastException
if another cannot be converted into something comparable to this instance.