java.lang
Class Byte
- java.lang.Object
-
- java.lang.Byte
-
public class Byte extends Object
-
-
Field Summary
Fields Modifier and Type Field and Description static byte
MAX_VALUE
Constant for the maximumByte
value, 27-1static byte
MIN_VALUE
Constant for the minimumByte
value, -27.
-
Constructor Summary
Constructors Constructor and Description Byte(byte value)
Constructs a newByte
with the specified primitive byte value.
-
Method Summary
Methods Modifier and Type Method and Description byte
byteValue()
Gets the primitive value of this byte.boolean
equals(Object object)
Compares this object with the specified object and indicates if they are equal.int
hashCode()
Returns an integer hash code for this byte.static byte
parseByte(String string)
Parses the specified string as a signed decimal byte value.static byte
parseByte(String string, int radix)
Parses the specified string as a signed byte value using the specified radix.String
toString()
Converts this byte into its decimal string representation.static Byte
valueOf(byte b)
Returns aByte
instance for the specified byte value.
-
-
-
Field Detail
-
MAX_VALUE
public static final byte MAX_VALUE
Constant for the maximumByte
value, 27-1- See Also:
- Constant Field Values
-
MIN_VALUE
public static final byte MIN_VALUE
Constant for the minimumByte
value, -27.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Byte
public Byte(byte value)
Constructs a newByte
with the specified primitive byte value.- Parameters:
value
- the primitive byte value to store in the new instance.
-
-
Method Detail
-
toString
public String toString()
Converts this byte into its decimal string representation. The returned string is a concatenation of a minus sign if the number is negative and characters from '0' to '9'.
-
byteValue
public byte byteValue()
Gets the primitive value of this byte.- Returns:
- this object's primitive value.
-
equals
public boolean equals(Object object)
Compares this object with the specified object and indicates if they are equal. In order to be equal,object
must be an instance ofByte
and have the same byte value as this object.- Overrides:
equals
in classObject
- Parameters:
object
- the object to compare this byte with.- Returns:
true
if the specified object is equal to thisByte
;false
otherwise.- See Also:
Object.hashCode()
-
hashCode
public int hashCode()
Returns an integer hash code for this byte.- Overrides:
hashCode
in classObject
- Returns:
- this object's hash code.
- See Also:
Object.equals(java.lang.Object)
-
parseByte
public static byte parseByte(String string) throws NumberFormatException
Parses the specified string as a signed decimal byte value. The ASCII character - ('-') is recognized as the minus sign.- Parameters:
string
- the string representation of a single byte value.- Returns:
- the primitive byte value represented by
string
. - Throws:
NumberFormatException
- ifstring
isnull
, has a length of zero or can not be parsed as a byte value.
-
parseByte
public static byte parseByte(String string, int radix) throws NumberFormatException
Parses the specified string as a signed byte value using the specified radix. The ASCII character - ('-') is recognized as the minus sign.- Parameters:
string
- the string representation of a single byte value.radix
- the radix to use when parsing.- Returns:
- the primitive byte value represented by
string
usingradix
. - Throws:
NumberFormatException
- ifstring
isnull
or has a length of zero,radix < Character.MIN_RADIX
,radix > Character.MAX_RADIX
, or ifstring
can not be parsed as a byte value.
-
valueOf
public static Byte valueOf(byte b)
Returns aByte
instance for the specified byte value.If it is not necessary to get a new
Byte
instance, it is recommended to use this method instead of the constructor, since it maintains a cache of instances which may result in better performance.- Parameters:
b
- the byte value to store in the instance.- Returns:
- a
Byte
instance containingb
. - Since:
- 1.5
-
-