introduction
the java.lang.byte class wraps a value of primitive type byte in an object. an object of type byte contains a single field whose type is byte.
class declaration
following is the declaration for java.lang.byte class −
public final class byte
extends number
implements comparable<byte>
field
following are the fields for java.lang.byte class −
static byte max_value − this is constant holding the maximum value a byte can have, 27-1.
static byte min_value − this is constant holding the minimum value a byte can have, -27.
static int size − this is the number of bits used to represent a byte value in two's complement binary form.
static class<byte> type − this is the class instance representing the primitive type byte.
class constructors
| sr.no. | constructor & description |
|---|---|
| 1 |
byte(byte value) this constructs a newly allocated byte object that represents the specified byte value. |
| 2 |
byte(string s) this constructs a newly allocated byte object that represents the byte value indicated by the string parameter. |
class methods
| sr.no. | method & description |
|---|---|
| 1 |
byte bytevalue()
this method returns the value of this byte as a byte. |
| 2 |
int compareto(byte anotherbyte)
this method compares two byte objects numerically. |
| 3 |
static byte decode(string nm)
this method decodes a string into a byte. |
| 4 |
double doublevalue()
this method returns the value of this byte as a double. |
| 5 |
boolean equals(object obj)
this method compares this object to the specified object. |
| 6 |
float floatvalue()
this method returns the value of this byte as a float. |
| 7 |
int hashcode()
this method returns a hash code for this byte. |
| 8 |
int intvalue()
this method returns the value of this byte as an int. |
| 9 |
long longvalue()
this method returns the value of this byte as a long. |
| 10 |
static byte parsebyte(string s)
this method parses the string argument as a signed decimal byte. |
| 11 |
static byte parsebyte(string s, int radix)
this method parses the string argument as a signed byte in the radix specified by the second argument. |
| 12 |
short shortvalue()
this method returns the value of this byte as a short. |
| 13 |
string tostring()
this method returns a string object representing this byte's value. |
| 14 |
static string tostring(byte b)
this method returns a new string object representing the specified byte. |
| 15 |
static byte valueof(byte b)
this method returns a byte instance representing the specified byte value. |
| 16 |
static byte valueof(string s)
this method returns a byte object holding the value given by the specified string. |
| 17 |
static byte valueof(string s, int radix)
this method returns a byte object holding the value extracted from the specified string when parsed with the radix given by the second argument. |
methods inherited
this class inherits methods from the following classes −
- java.lang.object