java.lang
Class Byte
java.lang.Object
|
+--java.lang.Number
|
+--java.lang.Byte
All Implemented Interfaces:
Comparable, Serializable
Instances of class Byte
represent primitive byte
values.
Additionally, this class provides various helper functions and variables
useful to bytes.
Since:Authors:- Paul Fisher
- John Keiser
- Per Bothner
- Eric Blake <ebb9@email.byu.edu>
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.
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:
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:
- the value of the String as a
Byte
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:
- whether these Objects are semantically equal
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:
- the
String
argument converted to byte
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:
- the
String
representation of this Byte
See Also:
toString
public static String toString(byte b)
Converts the byte
to a String
and assumes
a radix of 10.
Parameters:
Returns:
- the
String
representation of the argument
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:
Byte
represent primitivebyte
values. Additionally, this class provides various helper functions and variables useful to bytes.