GeezerVison is showing docs.oracle.com — Byte (Java Platform SE 8 )
Java™ Platform Standard Ed. 8
compact1, compact2, compact3
java.lang
Class Byte
-
-
Field Summary
Fields
| Modifier and Type |
Field |
Description |
static int |
BYTES |
The number of bytes used to represent a byte value in two's
complement binary form.
|
static byte |
MAX_VALUE |
A constant holding the maximum value a byte can
have, 27-1.
|
static byte |
MIN_VALUE |
A constant holding the minimum value a byte can
have, -27.
|
static int |
SIZE |
The number of bits used to represent a byte value in two's
complement binary form.
|
static Class<Byte> |
TYPE |
The Class instance representing the primitive type
byte.
|
-
Constructor Summary
Constructors
| Constructor |
Description |
Byte(byte value) |
Constructs a newly allocated Byte object that
represents the specified byte value.
|
Byte(String s) |
Constructs a newly allocated Byte object that
represents the byte value indicated by the
String parameter.
|
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods
| Modifier and Type |
Method |
Description |
byte |
byteValue() |
Returns the value of this Byte as a
byte.
|
static int |
compare(byte x,
byte y) |
Compares two byte values numerically.
|
int |
compareTo(Byte anotherByte) |
Compares two Byte objects numerically.
|
static Byte |
decode(String nm) |
Decodes a String into a Byte.
|
double |
doubleValue() |
Returns the value of this Byte as a double
after a widening primitive conversion.
|
boolean |
equals(Object obj) |
Compares this object to the specified object.
|
float |
floatValue() |
Returns the value of this Byte as a float after
a widening primitive conversion.
|
int |
hashCode() |
Returns a hash code for this Byte; equal to the result
of invoking intValue().
|
static int |
hashCode(byte value) |
Returns a hash code for a byte value; compatible with
Byte.hashCode().
|
int |
intValue() |
Returns the value of this Byte as an int after
a widening primitive conversion.
|
long |
longValue() |
Returns the value of this Byte as a long after
a widening primitive conversion.
|
static byte |
parseByte(String s) |
Parses the string argument as a signed decimal byte.
|
static byte |
parseByte(String s,
int radix) |
Parses the string argument as a signed byte in the
radix specified by the second argument.
|
short |
shortValue() |
Returns the value of this Byte as a short after
a widening primitive conversion.
|
String |
toString() |
Returns a String object representing this
Byte's value.
|
static String |
toString(byte b) |
Returns a new String object representing the
specified byte.
|
static int |
toUnsignedInt(byte x) |
Converts the argument to an int by an unsigned
conversion.
|
static long |
toUnsignedLong(byte x) |
Converts the argument to a long by an unsigned
conversion.
|
static Byte |
valueOf(byte b) |
Returns a Byte instance representing the specified
byte value.
|
static Byte |
valueOf(String s) |
Returns a Byte object holding the value
given by the specified String.
|
static Byte |
valueOf(String s,
int radix) |
Returns a Byte object holding the value
extracted from the specified String when parsed
with the radix given by the second argument.
|
-
-
Constructor Detail
-
Byte
public Byte(String s)
throws NumberFormatException
Constructs a newly allocated Byte object that
represents the byte value indicated by the
String parameter. The string is converted to a
byte value in exactly the manner used by the
parseByte method for radix 10.
- Parameters:
s - the String to be converted to a
Byte
- Throws:
NumberFormatException - If the String
does not contain a parsable byte.
- See Also:
parseByte(java.lang.String, int)
-
Method Detail
-
toString
public String toString()
Returns a String object representing this
Byte's value. The value is converted to signed
decimal representation and returned as a string, exactly as if
the byte value were given as an argument to the
toString(byte) method.
- Overrides:
toString in class Object
- Returns:
- a string representation of the value of this object in
base 10.
-
equals
public boolean equals(Object obj)
Compares this object to the specified object. The result is
true if and only if the argument is not
null and is a Byte object that
contains the same byte value as this object.
- Overrides:
equals in class Object
- Parameters:
obj - the object to compare with
- Returns:
true if the objects are the same;
false otherwise.
- See Also:
Object.hashCode(),
HashMap
-
toUnsignedInt
public static int toUnsignedInt(byte x)
Converts the argument to an int by an unsigned
conversion. In an unsigned conversion to an int, the
high-order 24 bits of the int are zero and the
low-order 8 bits are equal to the bits of the byte argument.
Consequently, zero and positive byte values are mapped
to a numerically equal int value and negative byte values are mapped to an int value equal to the
input plus 28.
- Parameters:
x - the value to convert to an unsigned int
- Returns:
- the argument converted to
int by an unsigned
conversion
- Since:
- 1.8
-
toUnsignedLong
public static long toUnsignedLong(byte x)
Converts the argument to a long by an unsigned
conversion. In an unsigned conversion to a long, the
high-order 56 bits of the long are zero and the
low-order 8 bits are equal to the bits of the byte argument.
Consequently, zero and positive byte values are mapped
to a numerically equal long value and negative byte values are mapped to a long value equal to the
input plus 28.
- Parameters:
x - the value to convert to an unsigned long
- Returns:
- the argument converted to
long by an unsigned
conversion
- Since:
- 1.8
Java™ Platform Standard Ed. 8
Submit a bug or feature For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples. Copyright © 1993, 2026, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.
|