加载中...
The Wayback Machine - https://sup1a9wrlpyh5li9ro.vcoronado.top/web/20090228220345/http://developer.android.com:80/reference/java/lang/Byte.html
public final class

Byte

extends Number
implements Comparable<T>
java.lang.Object
   ↳ java.lang.Number
     ↳ java.lang.Byte

Class Overview

Byte is the wrapper for the primitive type byte.

Summary

Constants
byte MAX_VALUE

Constant for the maximum byte value, 27-1.

byte MIN_VALUE

Constant for the minimum byte value, -27.

int SIZE

Constant for the number of bits to represent a byte in two's compliment form.

Class<Byte> TYPE The java.lang.Class that represents this class.
Public Constructors
Byte(byte value)
Constructs a new instance of the receiver which represents the byte valued argument.
Byte(String string)
Constructs a new instance of this class given a string.
Public Methods
byte byteValue()
Returns the byte value which the receiver represents
int compareTo(Byte object)

Compares this Byte to the Byte passed.

static Byte decode(String string)
Parses the string argument as if it was a byte value and returns the result.
double doubleValue()
Returns the double value which the receiver represents
boolean equals(Object object)
Compares the argument to the receiver, and returns true if they represent the same object using a class specific comparison.
float floatValue()
Returns the float value which the receiver represents
int hashCode()
Returns an integer hash code for the receiver.
int intValue()
Returns the int value which the receiver represents
long longValue()
Returns the long value which the receiver represents
static byte parseByte(String string, int radix)
Parses the string argument as if it was a byte value and returns the result.
static byte parseByte(String string)
Parses the string argument as if it was a byte value and returns the result.
short shortValue()
Returns the short value which the receiver represents
String toString()
Returns a string containing a concise, human-readable description of the receiver.
static String toString(byte value)
Returns a string containing a concise, human-readable description of the argument.
static Byte valueOf(String string, int radix)
Parses the string argument as if it was a byte value and returns a Byte representing the result.
static Byte valueOf(String string)
Parses the string argument as if it was a byte value and returns a Byte representing the result.
static Byte valueOf(byte b)

Returns a Byte instance for the byte value passed.

[Expand]
Inherited Methods
From class java.lang.Number
From class java.lang.Object
From interface java.lang.Comparable

Constants

public static final byte MAX_VALUE

Constant for the maximum byte value, 27-1.

Constant Value: 127 (0x0000007f)

public static final byte MIN_VALUE

Constant for the minimum byte value, -27.

Constant Value: -128 (0xffffff80)

public static final int SIZE

Constant for the number of bits to represent a byte in two's compliment form.

Constant Value: 8 (0x00000008)

public static final Class<Byte> TYPE

The java.lang.Class that represents this class.

Public Constructors

public Byte (byte value)

Constructs a new instance of the receiver which represents the byte valued argument.

Parameters
value the byte to store in the new instance.

public Byte (String string)

Constructs a new instance of this class given a string.

Parameters
string a string representation of a single byte quantity.
Throws
NumberFormatException if the argument could not be parsed as a byte quantity.

Public Methods

public byte byteValue ()

Returns the byte value which the receiver represents

Returns
  • byte the value of the receiver.

public int compareTo (Byte object)

Compares this Byte to the Byte passed. If this instance's value is equal to the value of the instance passed, then 0 is returned. If this instance's value is less than the value of the instance passed, then a negative value is returned. If this instance's value is greater than the value of the instance passed, then a positive value is returned.

Parameters
object The instance to compare to.
Throws
NullPointerException if object is null.

public static Byte decode (String string)

Parses the string argument as if it was a byte value and returns the result. It is an error if the received string does not contain a representation of a single byte quantity. The string may be a hexadecimal ("0x..."), octal ("0..."), or decimal ("...") representation of a byte.

Parameters
string a string representation of a single byte quantity.
Returns
  • Byte the value represented by the argument
Throws
NumberFormatException if the argument could not be parsed as a byte quantity.

public double doubleValue ()

Returns the double value which the receiver represents

Returns
  • double the value of the receiver.

public boolean equals (Object object)

Compares the argument to the receiver, and returns true if they represent the same object using a class specific comparison.

In this case, the argument must also be a Byte, and the receiver and argument must represent the same byte value.

Parameters
object the object to compare with this object
Returns
  • true if the object is the same as this object false if it is different from this object
See Also

public float floatValue ()

Returns the float value which the receiver represents

Returns
  • float the value of the receiver.

public int hashCode ()

Returns an integer hash code for the receiver. Any two objects which answer true when passed to equals must answer the same value for this method.

Returns
  • the receiver's hash
See Also

public int intValue ()

Returns the int value which the receiver represents

Returns
  • int the value of the receiver.

public long longValue ()

Returns the long value which the receiver represents

Returns
  • long the value of the receiver.

public static byte parseByte (String string, int radix)

Parses the string argument as if it was a byte value and returns the result. Throws NumberFormatException if the string does not represent a single byte quantity. The second argument specifies the radix to use when parsing the value.

Parameters
string a string representation of a single byte quantity.
radix the radix to use when parsing.
Returns
  • byte the value represented by the argument
Throws
NumberFormatException if the argument could not be parsed as a byte quantity.

public static byte parseByte (String string)

Parses the string argument as if it was a byte value and returns the result. Throws NumberFormatException if the string does not represent a single byte quantity.

Parameters
string a string representation of a single byte quantity.
Returns
  • byte the value represented by the argument
Throws
NumberFormatException if the argument could not be parsed as a byte quantity.

public short shortValue ()

Returns the short value which the receiver represents

Returns
  • short the value of the receiver.

public String toString ()

Returns a string containing a concise, human-readable description of the receiver.

Returns
  • a printable representation for the receiver.

public static String toString (byte value)

Returns a string containing a concise, human-readable description of the argument.

Parameters
value byte the byte to convert.
Returns
  • String a printable representation for the byte.

public static Byte valueOf (String string, int radix)

Parses the string argument as if it was a byte value and returns a Byte representing the result. Throws NumberFormatException if the string cannot be parsed as a byte quantity. The second argument specifies the radix to use when parsing the value.

Parameters
string a string representation of a single byte quantity.
radix the radix to use when parsing.
Returns
  • Byte the value represented by the argument
Throws
NumberFormatException if the argument could not be parsed as a byte quantity.

public static Byte valueOf (String string)

Parses the string argument as if it was a byte value and returns a Byte representing the result. Throws NumberFormatException if the string cannot be parsed as a byte quantity.

Parameters
string a string representation of a single byte quantity.
Returns
  • Byte the value represented by the argument
Throws
NumberFormatException if the argument could not be parsed as a byte quantity.

public static Byte valueOf (byte b)

Returns a Byte instance for the byte value passed. This method is preferred over the constructor, as this method may maintain a cache of instances.

Parameters
b The byte value.
Returns
  • A Byte instance.