aicas logoJamaica 6.4 release 1

java.lang
Class Byte

java.lang.Object
  extended by java.lang.Number
      extended by java.lang.Byte
All Implemented Interfaces:
Serializable, Comparable<Byte>

public final class Byte
extends Number
implements Comparable<Byte>

Byte provides a class for byte values stored in objects.

Since:
1.1
See Also:
Serialized Form

Field Summary
static byte MAX_VALUE
          The largest value a byte can hold.
static byte MIN_VALUE
          The smallest value a byte can hold.
static int SIZE
          The size occupied by one byte in bits.
static Class<Byte> TYPE
          type for byte.
 
Constructor Summary
Byte(byte value)
          Constructor to create an instance of Byte with the given byte value.
Byte(String s)
          Constructor to create an instance of Byte with the value provided as a string.
 
Method Summary
 byte byteValue()
          byteValue returns the value of this as a byte.
 int compareTo(Byte o)
          compareTo compares this to another byte value
static Byte decode(String s)
          decode decodes a string containing decimal, hexadecimal or octal representation of a byte.
 double doubleValue()
          doubleValue returns the value of this as a short.
 boolean equals(Object obj)
          equals checks if this and obj represent the same value.
 float floatValue()
          floatValue returns the value of this as a short.
 int hashCode()
          hashCode returns a hashCode for this Byte.
 int intValue()
          intValue returns the value of this as a short.
 long longValue()
          longValue returns the value of this as a short.
static byte parseByte(String s)
          parseByte parse a string that contains the decimal representation of a byte and returns the byte's value.
static byte parseByte(String s, int radix)
          parseByte parses a string that contains a byte represented by a number using the given radix.
 short shortValue()
          shortValue returns the value of this as a short.
 String toString()
          toString converts the value of this byte to a decimal string.
static String toString(byte b)
          toString creates a decimal string from the given byte value.
static Byte valueOf(byte b)
          valueOf returns a byte instance with the given value.
static Byte valueOf(String s)
          valueOf returns a byte instance with the value given as a decimal string.
static Byte valueOf(String s, int radix)
          valueOf returns a byte instance with the value given as a string with given radix.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

MIN_VALUE

public static final byte MIN_VALUE
The smallest value a byte can hold.

See Also:
Constant Field Values

MAX_VALUE

public static final byte MAX_VALUE
The largest value a byte can hold.

See Also:
Constant Field Values

SIZE

public static final int SIZE
The size occupied by one byte in bits.

Since:
1.5
See Also:
Constant Field Values

TYPE

public static final Class<Byte> TYPE
type for byte.

Since:
1.1
Constructor Detail

Byte

public Byte(byte value)
Constructor to create an instance of Byte with the given byte value.

Parameters:
value - the value for this instance.

Byte

public Byte(String s)
     throws NumberFormatException
Constructor to create an instance of Byte with the value provided as a string.

Parameters:
s - the string representation of the value.
Throws:
NumberFormatException - if s could not be parsed as a byte.
Method Detail

valueOf

public static Byte valueOf(byte b)
valueOf returns a byte instance with the given value. A cache is used to avoid multiple allocations of the same Byte instance.

Parameters:
b - the byte value
Returns:
an instance with value equal to b.
Since:
1.5

toString

public static String toString(byte b)
toString creates a decimal string from the given byte value.

Parameters:
b - the byte value
Returns:
the corresponding decimal string, e.g. "-128", "3", "127".

parseByte

public static byte parseByte(String s)
                      throws NumberFormatException
parseByte parse a string that contains the decimal representation of a byte and returns the byte's value.

Parameters:
s - the string, e.g, "-128", "3", "127".
Returns:
the byte value.
Throws:
NumberFormatException - if s is not parsable or out of the legal range for bytes.

parseByte

public static byte parseByte(String s,
                             int radix)
                      throws NumberFormatException
parseByte parses a string that contains a byte represented by a number using the given radix. Returns the byte's value.

Parameters:
s - the string
radix - the radix
Returns:
the byte value.
Throws:
NumberFormatException - if s is not parsable, radix is out of the legal range or the value is out of the legal range for bytes.

valueOf

public static Byte valueOf(String s,
                           int radix)
                    throws NumberFormatException
valueOf returns a byte instance with the value given as a string with given radix. A cache is used to avoid multiple allocations of the same Byte instance.

Parameters:
s - the string
radix - the radix
Returns:
a Byte instance with the given value.
Throws:
NumberFormatException - if s is not parsable, radix is out of the legal range or the value is out of the legal range for bytes.

valueOf

public static Byte valueOf(String s)
                    throws NumberFormatException
valueOf returns a byte instance with the value given as a decimal string. A cache is used to avoid multiple allocations of the same Byte instance.

Parameters:
s - the string, e.g, "-128", "3", "127".
Returns:
a Byte instance with the given value.
Throws:
NumberFormatException - if s is not parsable or the value is out of the legal range for bytes.

decode

public static Byte decode(String s)
                   throws NumberFormatException
decode decodes a string containing decimal, hexadecimal or octal representation of a byte.

Parameters:
s - the string representation, e.g. "0x7f", "-0X80", "-#3F", "-0100", "123"
Returns:
a Byte instance with the given value.
Throws:
NumberFormatException - if s is not parsable or the value is out of the legal range for bytes.

byteValue

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

Overrides:
byteValue in class Number
Returns:
the value converted to byte.

shortValue

public short shortValue()
shortValue returns the value of this as a short.

Overrides:
shortValue in class Number
Returns:
the value converted to short.

intValue

public int intValue()
intValue returns the value of this as a short.

Specified by:
intValue in class Number
Returns:
the value converted to int.

longValue

public long longValue()
longValue returns the value of this as a short.

Specified by:
longValue in class Number
Returns:
the value converted to long.

floatValue

public float floatValue()
floatValue returns the value of this as a short.

Specified by:
floatValue in class Number
Returns:
the value converted to float.

doubleValue

public double doubleValue()
doubleValue returns the value of this as a short.

Specified by:
doubleValue in class Number
Returns:
the value converted to double.

toString

public String toString()
toString converts the value of this byte to a decimal string.

Overrides:
toString in class Object
Returns:
the string, e.g. "-128", "127", "3".

hashCode

public int hashCode()
hashCode returns a hashCode for this Byte.

Overrides:
hashCode in class Object
Returns:
the byte value as hash code.

equals

public boolean equals(Object obj)
equals checks if this and obj represent the same value.

Overrides:
equals in class Object
Parameters:
obj - another object
Returns:
true of obj is a Byte that represents the same value as this.

compareTo

public int compareTo(Byte o)
compareTo compares this to another byte value

Specified by:
compareTo in interface Comparable<Byte>
Parameters:
o - the other byte
Returns:
-1 if this is smaller than, 0 if this is equal to, +1 if this is larger than o.
Since:
1.2

aicas logoJamaica 6.4 release 1

aicas GmbH, Karlsruhe, Germany —www.aicas.com
Copyright © 2001-2015 aicas GmbH. All Rights Reserved.