Facebook Page Twitter Page LinkedIn Page
× Java.lang Package Classes


Java Byte Class

Java.lang package provides a Byte class which wraps a value of primitive type byte in an object. An object of type Byte contains a single field whose type is byte.

In addition, this class provides several methods for converting a byte to a String and a String to a byte, as well as other constants and methods useful when dealing with a byte.

Class declaration

The declaration of java.lang.Byte class is:

public final class Byte
  extends Number
    implements Comparable<Byte>

Fields

S.NFields & Description
1. static int BYTES
The number of bytes used to represent a byte value in two's complement binary form.
2. static byte MAX_VALUE
A constant holding the maximum value a byte can have, 27-1.
3. static byte MIN_VALUE
A constant holding the minimum value a byte can have, -27.
4. static int SIZE
The number of bits used to represent a byte value in two's complement binary form.
5. static Class<Byte> TYPE
The Class instance representing the primitive type byte.

Class Constructors

S.NConstructors & Description
1. Byte(byte value)
Constructs a newly allocated Byte object that represents the specified byte value.
2. Byte(String s)
Constructs a newly allocated Byte object that represents the byte value indicated by the String parameter.

java.lang.Byte Methods

The java.lang.Byte class has a number of methods which are listed below:

Member Methods

S.NMethods & Description
1. byte byteValue()
Returns the value of this Byte as a byte.
2. static int compare(byte x, byte y)
Compares two byte values numerically.
3. int compareTo(Byte anotherByte)
Compares two Byte objects numerically.
4. static Byte decode(String nm)
Decodes a String into a Byte.
5. double doubleValue()
Returns the value of this Byte as a double after a widening primitive conversion.
6. boolean equals(Object obj)
Compares this object to the specified object.
7. float floatValue()
Returns the value of this Byte as a float after a widening primitive conversion.
8. int hashCode()
Returns a hash code for this Byte; equal to the result of invoking intValue().
9. static int hashCode(byte value)
Returns a hash code for a byte value; compatible with Byte.hashCode().
10. int intValue()
Returns the value of this Byte as an int after a widening primitive conversion.
11. long longValue()
Returns the value of this Byte as a long after a widening primitive conversion.
12. static byte parseByte(String s)
Parses the string argument as a signed decimal byte.
13. static byte parseByte(String s, int radix)
Parses the string argument as a signed byte in the radix specified by the second argument.
14. short shortValue()
Returns the value of this Byte as a short after a widening primitive conversion.
15. String toString()
Returns a String object representing this Byte's value.
16. static String toString(byte b)
Returns a new String object representing the specified byte.
17. static int toUnsignedInt(byte x)
Converts the argument to an int by an unsigned conversion.
18. static long toUnsignedLong(byte x)
Converts the argument to a long by an unsigned conversion.
19. static Byte valueOf(byte b)
Returns a Byte instance representing the specified byte value.
20. static Byte valueOf(String s)
Returns a Byte object holding the value given by the specified String.
21. 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.

Methods inherited

This class inherits the methods of following class:

  • java.lang.Object
  • java.lang.Number