Index (Frames) | Index (No Frames) | Package | Package Tree | Tree
java.lang

Class Byte

java.lang.Object
|
+--java.lang.Number
   |
   +--java.lang.Byte

All Implemented Interfaces:

Comparable, Serializable


public final class Byte

extends Number

implements Comparable

Instances of class Byte represent primitive byte values. Additionally, this class provides various helper functions and variables useful to bytes.

Since:Authors:

Field Summary

static byteMAX_VALUE

The maximum value a byte can represent is 127 (or 27 - 1).
static byteMIN_VALUE

The minimum value a byte can represent is -128 (or -27).
static java.lang.ClassTYPE

The primitive type byte is represented by this Class object.

Constructor Summary

Byte(byte value)

Create a Byte object representing the value of the byte argument.
Byte(java.lang.String s)

Create a Byte object representing the value specified by the String argument

Method Summary

bytebyteValue()

Return the value of this Byte.
intcompareTo(java.lang.Byte b)

Compare two Bytes numerically by comparing their byte values.
intcompareTo(java.lang.Object o)

Behaves like compareTo(Byte) unless the Object is not a Byte.
static java.lang.Bytedecode(java.lang.String s)

Convert the specified String into a Byte.
doubledoubleValue()

Return the value of this Byte as a double.
booleanequals(java.lang.Object obj)

Returns true if obj is an instance of Byte and represents the same byte value.
floatfloatValue()

Return the value of this Byte as a float.
inthashCode()

Return a hashcode representing this Object.
intintValue()

Return the value of this Byte as an int.
longlongValue()

Return the value of this Byte as a long.
static byteparseByte(java.lang.String s)

Converts the specified String into a byte.
static byteparseByte(java.lang.String s, int radix)

Converts the specified String into an int using the specified radix (base).
shortshortValue()

Return the value of this Byte as a short.
static java.lang.StringtoString(byte b)

Converts the byte to a String and assumes a radix of 10.
java.lang.StringtoString()

Converts the Byte value to a String and assumes a radix of 10.
static java.lang.BytevalueOf(java.lang.String s, int radix)

Creates a new Byte object using the String and specified radix (base).
static java.lang.BytevalueOf(java.lang.String s)

Creates a new Byte object using the String, assuming a radix of 10.

Field Details

MAX_VALUE

public static final byte MAX_VALUE

The maximum value a byte can represent is 127 (or 27 - 1).


MIN_VALUE

public static final byte MIN_VALUE

The minimum value a byte can represent is -128 (or -27).


TYPE

public static final Class TYPE

The primitive type byte is represented by this Class object.


Constructor Details

Byte

public Byte(byte value)

Create a Byte object representing the value of the byte argument.

Parameters:


Byte

public Byte(java.lang.String s)

Create a Byte object representing the value specified by the String argument

Parameters:

Throws:

See Also:


Method Details

byteValue

public byte byteValue()

Return the value of this Byte.

Returns:


compareTo

public int compareTo(java.lang.Byte b)

Compare two Bytes numerically by comparing their byte values. The result is positive if the first is greater, negative if the second is greater, and 0 if the two are equal.

Since:Parameters:

Returns:


compareTo

public int compareTo(java.lang.Object o)

Behaves like compareTo(Byte) unless the Object is not a Byte.

Since:Parameters:

Returns:

Throws:

See Also:


decode

public static Byte decode(java.lang.String s)

Convert the specified String into a Byte. The String may represent decimal, hexadecimal, or octal numbers.

The extended BNF grammar is as follows:

 DecodableString:
      ( [ - ] DecimalNumber )
    | ( [ - ] ( 0x | 0X
              | # ) { HexDigit }+ )
    | ( [ - ] 0 { OctalDigit } )
 DecimalNumber:
        DecimalDigit except '0' { DecimalDigit }
 DecimalDigit:
        Character.digit(d, 10) has value 0 to 9
 OctalDigit:
        Character.digit(d, 8) has value 0 to 7
 DecimalDigit:
        Character.digit(d, 16) has value 0 to 15
 
Finally, the value must be in the range MIN_VALUE to MAX_VALUE, or an exception is thrown.

Parameters:

Returns:

Throws:

See Also:


doubleValue

public double doubleValue()

Return the value of this Byte as a double.

Returns:


equals

public boolean equals(java.lang.Object obj)

Returns true if obj is an instance of Byte and represents the same byte value.

Parameters:

Returns:


floatValue

public float floatValue()

Return the value of this Byte as a float.

Returns:


hashCode

public int hashCode()

Return a hashcode representing this Object. Byte's hash code is simply its value.

Returns:


intValue

public int intValue()

Return the value of this Byte as an int.

Returns:


longValue

public long longValue()

Return the value of this Byte as a long.

Returns:


parseByte

public static byte parseByte(java.lang.String s)

Converts the specified String into a byte. This function assumes a radix of 10.

Parameters:

Returns:

Throws:

See Also:


parseByte

public static byte parseByte(java.lang.String s, int radix)

Converts the specified String into an int using the specified radix (base). The string must not be null or empty. It may begin with an optional '-', which will negate the answer, provided that there are also valid digits. Each digit is parsed as if by Character.digit(d, radix), and must be in the range 0 to radix - 1. Finally, the result must be within MIN_VALUE to MAX_VALUE, inclusive. Unlike Double.parseDouble, you may not have a leading '+'.

Parameters:

Returns:

Throws:


shortValue

public short shortValue()

Return the value of this Byte as a short.

Returns:


toString

public String toString()

Converts the Byte value to a String and assumes a radix of 10.

Returns:

See Also:


toString

public static String toString(byte b)

Converts the byte to a String and assumes a radix of 10.

Parameters:

Returns:


valueOf

public static Byte valueOf(java.lang.String s)

Creates a new Byte object using the String, assuming a radix of 10.

Parameters:

Returns:

Throws:

See Also:


valueOf

public static Byte valueOf(java.lang.String s, int radix)

Creates a new Byte object using the String and specified radix (base).

Parameters:

Returns:

Throws:

See Also: