Method from java.lang.Byte Detail: |
public byte byteValue() {
return value;
}
Returns the value of this {@code Byte} as a
{@code byte}. |
public static int compare(byte x,
byte y) {
return x - y;
}
Compares two {@code byte} values numerically.
The value returned is identical to what would be returned by:
Byte.valueOf(x).compareTo(Byte.valueOf(y))
|
public int compareTo(Byte anotherByte) {
return compare(this.value, anotherByte.value);
}
Compares two {@code Byte} objects numerically. |
public static Byte decode(String nm) throws NumberFormatException {
int i = Integer.decode(nm);
if (i < MIN_VALUE || i > MAX_VALUE)
throw new NumberFormatException(
"Value " + i + " out of range from input " + nm);
return valueOf((byte)i);
}
Decodes a {@code String} into a {@code Byte}.
Accepts decimal, hexadecimal, and octal numbers given by
the following grammar:
- DecodableString:
- Signopt DecimalNumeral
- Signopt {@code 0x} HexDigits
- Signopt {@code 0X} HexDigits
- Signopt {@code #} HexDigits
- Signopt {@code 0} OctalDigits
- Sign:
- {@code -}
- {@code +}
DecimalNumeral, HexDigits, and OctalDigits
are as defined in section 3.10.1 of
The Java™ Language Specification,
except that underscores are not accepted between digits.
The sequence of characters following an optional
sign and/or radix specifier ("{@code 0x}", "{@code 0X}",
"{@code #}", or leading zero) is parsed as by the {@code
Byte.parseByte} method with the indicated radix (10, 16, or 8).
This sequence of characters must represent a positive value or
a NumberFormatException will be thrown. The result is
negated if first character of the specified {@code String} is
the minus sign. No whitespace characters are permitted in the
{@code String}. |
public double doubleValue() {
return (double)value;
}
Returns the value of this {@code Byte} as a
{@code double}. |
public boolean equals(Object obj) {
if (obj instanceof Byte) {
return value == ((Byte)obj).byteValue();
}
return false;
}
Compares this object to the specified object. The result is
{@code true} if and only if the argument is not
{@code null} and is a {@code Byte} object that
contains the same {@code byte} value as this object. |
public float floatValue() {
return (float)value;
}
Returns the value of this {@code Byte} as a
{@code float}. |
public int hashCode() {
return (int)value;
}
Returns a hash code for this {@code Byte}; equal to the result
of invoking {@code intValue()}. |
public int intValue() {
return (int)value;
}
Returns the value of this {@code Byte} as an
{@code int}. |
public long longValue() {
return (long)value;
}
Returns the value of this {@code Byte} as a
{@code long}. |
public static byte parseByte(String s) throws NumberFormatException {
return parseByte(s, 10);
}
Parses the string argument as a signed decimal {@code
byte}. The characters in the string must all be decimal digits,
except that the first character may be an ASCII minus sign
{@code '-'} ('\u002D' ) to indicate a negative
value or an ASCII plus sign {@code '+'}
('\u002B' ) to indicate a positive value. The
resulting {@code byte} value is returned, exactly as if the
argument and the radix 10 were given as arguments to the #parseByte(java.lang.String, int) method. |
public static byte parseByte(String s,
int radix) throws NumberFormatException {
int i = Integer.parseInt(s, radix);
if (i < MIN_VALUE || i > MAX_VALUE)
throw new NumberFormatException(
"Value out of range. Value:\"" + s + "\" Radix:" + radix);
return (byte)i;
}
Parses the string argument as a signed {@code byte} in the
radix specified by the second argument. The characters in the
string must all be digits, of the specified radix (as
determined by whether java.lang.Character#digit(char,
int) returns a nonnegative value) except that the first
character may be an ASCII minus sign {@code '-'}
('\u002D' ) to indicate a negative value or an
ASCII plus sign {@code '+'} ('\u002B' ) to
indicate a positive value. The resulting {@code byte} value is
returned.
An exception of type {@code NumberFormatException} is
thrown if any of the following situations occurs:
- The first argument is {@code null} or is a string of
length zero.
- The radix is either smaller than java.lang.Character#MIN_RADIX or larger than java.lang.Character#MAX_RADIX .
- Any character of the string is not a digit of the
specified radix, except that the first character may be a minus
sign {@code '-'} (
'\u002D' ) or plus sign
{@code '+'} ('\u002B' ) provided that the
string is longer than length 1.
- The value represented by the string is not a value of type
{@code byte}.
|
public short shortValue() {
return (short)value;
}
Returns the value of this {@code Byte} as a
{@code short}. |
public String toString() {
return Integer.toString((int)value);
}
Returns a {@code String} object representing this
{@code Byte}'s value. The value is converted to signed
decimal representation and returned as a string, exactly as if
the {@code byte} value were given as an argument to the
java.lang.Byte#toString(byte) method. |
public static String toString(byte b) {
return Integer.toString((int)b, 10);
}
Returns a new {@code String} object representing the
specified {@code byte}. The radix is assumed to be 10. |
public static Byte valueOf(byte b) {
final int offset = 128;
return ByteCache.cache[(int)b + offset];
}
Returns a {@code Byte} instance representing the specified
{@code byte} value.
If a new {@code Byte} instance is not required, this method
should generally be used in preference to the constructor
#Byte(byte) , as this method is likely to yield
significantly better space and time performance since
all byte values are cached. |
public static Byte valueOf(String s) throws NumberFormatException {
return valueOf(s, 10);
}
Returns a {@code Byte} object holding the value
given by the specified {@code String}. The argument is
interpreted as representing a signed decimal {@code byte},
exactly as if the argument were given to the #parseByte(java.lang.String) method. The result is a
{@code Byte} object that represents the {@code byte}
value specified by the string.
In other words, this method returns a {@code Byte} object
equal to the value of:
{@code new Byte(Byte.parseByte(s))}
|
public static Byte valueOf(String s,
int radix) throws NumberFormatException {
return valueOf(parseByte(s, radix));
}
Returns a {@code Byte} object holding the value
extracted from the specified {@code String} when parsed
with the radix given by the second argument. The first argument
is interpreted as representing a signed {@code byte} in
the radix specified by the second argument, exactly as if the
argument were given to the #parseByte(java.lang.String,
int) method. The result is a {@code Byte} object that
represents the {@code byte} value specified by the string.
In other words, this method returns a {@code Byte} object
equal to the value of:
{@code new Byte(Byte.parseByte(s, radix))}
|