java.lang.Byte
java.lang.Number
None
None
New as of JDK 1.1
The Byte class provides an object wrapper for a byte value. This is useful when you need to treat a byte value as an object. For example, there are a number of utility methods that take a reference to an Object as one of their arguments. You cannot specify a byte value for one of these arguments, but you can provide a reference to a Byte object that encapsulates the byte value. Furthermore, the Byte class is necessary as of JDK 1.1 to support the Reflection API and class literals.
The Byte class also provides a number of utility methods for converting byte values to other primitive types and for converting byte values to strings and vice versa.
public final class java.lang.Byte extends java.lang.Number { // Constants public static final byte MAX_VALUE; public static final byte MIN_VALUE; public static final Class TYPE; // Constructors public Byte(byte value); public Byte(String s); // Class Methods public static Byte decode(String nm); public static byte parseByte(String s); public static byte parseByte(String s, int radix); public static String toString(byte b); public static Byte valueOf(String s, int radix); public static Byte valueOf(String s); // Instance Methods public byte byteValue(); public double doubleValue; public boolean equals(Object obj); public float floatValue public int hashCode(); public int intValue(); public long longValue(); public short shortValue(); public String toString(); }
The largest value that can be represented by a byte.
The smallest value that can be represented by a byte.
The Class object that represents the primitive type byte. It is always true that Byte.TYPE == byte.class.
The byte value to be encapsulated by this object.
Creates a Byte object with the specified byte value.
The string to be made into a Byte object.
If the sequence of characters in the given String does not form a valid byte literal.
Constructs a Byte object with the value specified by the given string. The string should consist of one or more digit characters. The digit characters can be preceded by a single `-' character. If the string contains any other characters, the constructor throws a NumberFormatException.
A String representation of the value to be encapsulated by a Byte object. If the string begins with # or 0x, it is a radix 16 representation of the value. If the string begins with 0, it is a radix 8 representation of the value. Otherwise, it is assumed to be a radix 10 representation of the value.
A Byte object that encapsulates the given value.
If the String contains any non-digit characters other than a leading minus sign or the value represented by the String is less than Byte.MIN_VALUE or greater than Byte.MAX_VALUE.
This method returns a Byte object that encapsulates the given value.
The String to be converted to a byte value.
The numeric value of the byte represented by the String object.
If the String does not contain a valid representation of a byte or the value represented by the String is less than Byte.MIN_VALUE or greater than Byte.MAX_VALUE.
This method returns the numeric value of the byte represented by the contents of the given String object. The String must contain only decimal digits, except that the first character may be a minus sign.
public static byte parseByte(String s, int radix) throws NumberFormatException
The String to be converted to a byte value.
The radix used in interpreting the characters in the String as digits. This value must be in the range Character.MIN_RADIX to Character.MAX_RADIX. If radix is in the range 2 through 10, only characters for which the Character.isDigit() method returns true are considered to be valid digits. If radix is in the range 11 through 36, characters in the ranges `A' through `Z' and `a' through `z' may be considered valid digits.
The numeric value of the byte represented by the String object in the specified radix.
If the String does not contain a valid representation of a byte, radix is not in the appropriate range, or the value represented by the String is less than Byte.MIN_VALUE or greater than Byte.MAX_VALUE.
This method returns the numeric value of the byte represented by the contents of the given String object in the specified radix. The String must contain only valid digits of the specified radix, except that the first character may be a minus sign. The digits are parsed in the specified radix to produce the numeric value.
The byte value to be converted to a string.
The string representation of the given value.
This method returns a String object that contains the decimal representation of the given value.
This method returns a string that begins with `-' if the given value is negative. The rest of the string is a sequence of one or more of the characters `0', `1', `2', `3', `4', `5', `6', `7', `8', and `9'. This method returns "0" if its argument is 0. Otherwise, the string returned by this method does not begin with "0" or "-0".
The string to be made into a Byte object.
The Byte object constructed from the string.
If the String does not contain a valid representation of a byte or the value represented by the String is less than Byte.MIN_VALUE or greater than Byte.MAX_VALUE.
Constructs a Byte object with the value specified by the given string. The string should consist of one or more digit characters. The digit characters can be preceded by a single `-' character. If the string contains any other characters, the method throws a NumberFormatException.
public static Byte valueOf(String s, int radix) throws NumberFormatException
The string to be made into a Byte object.
The radix used in converting the string to a value. This value must be in the range Character.MIN_RADIX to Character.MAX_RADIX.
The Byte object constructed from the string.
If the String does not contain a valid representation of a byte, radix is not in the appropriate range, or the value represented by the String is less than Byte.MIN_VALUE or greater than Byte.MAX_VALUE.
Constructs a Byte object with the value specified by the given string in the specified radix. The string should consist of one or more digit characters or characters in the range `A' to `Z' or `a' to `z' that are considered digits in the given radix. The digit characters can be preceded by a single `-' character. If the string contains any other characters, the method throws a NumberFormatException.
The value of this object as a byte.
Number.byteValue()
This method returns the value of this object as a byte.
The value of this object as a double.
Number.doubleValue()
This method returns the value of this object as a double.
The object to be compared with this object.
true if the objects are equal; false if they are not.
Object.equals()
This method returns true if obj is an instance of Byte and it contains the same value as the object this method is associated with.
The value of this object as a float.
Number.floatValue()
This method returns the value of this object as a float.
A hashcode based on the byte value of the object.
Object.hashCode()
This method returns a hashcode computed from the value of this object.
The value of this object as an int.
Number.intValue()
This method returns the value of this object as an int.
The value of this object as a long.
Number.longValue()
This method returns the value of this object as a long.
The value of this object as a short.
Number.shortValue()
This method returns the value of this object as a short.
The string representation of the value of this object.
Object.toString()
This method returns a String object that contains the decimal representation of the value of this object.
This method returns a string that begins with `-` if the given value is negative. The rest of the string is a sequence of one or more of the characters `0', `1', `2', `3', `4', `5', `6', `7', `8', and `9'. This method returns "0" if its argument is 0. Otherwise, the string returned by this method does not begin with "0" or "-0".
Method |
Inherited From |
Method |
Inherited From |
---|---|---|---|
clone() |
Object |
finalize() |
Object |
getClass() |
Object |
notify() |
Object |
notifyAll() |
Object |
wait() |
Object |
wait(long) |
Object |
wait(long, int) |
Object |
Character; Class; Double; Exceptions; Float; Integer literals; Integer types; Integer; Long; Number; Short; String