Class Byte

All Implemented Interfaces:
Comparable<Byte>

public final class Byte extends Number implements Comparable<Byte>
The Byte class is the standard wrapper for byte values. Since: JDK1.1, CLDC 1.0
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final byte
    The maximum value a Byte can have.
    static final byte
    The minimum value a Byte can have.
    static final int
     
    static final Class<Byte>
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Byte(byte value)
    Constructs a Byte object initialized to the specified byte value.
  • Method Summary

    Modifier and Type
    Method
    Description
    byte
    Returns the value of this Byte as a byte.
    int
    compare(byte b1, byte b2)
     
    int
    Compares this object to the specified object to determine their relative order.
    double
     
    boolean
    Compares this object to the specified object.
    float
     
    int
    Returns a hashcode for this Byte.
    int
     
    long
     
    static byte
    Assuming the specified String represents a byte, returns that byte's value.
    static byte
    parseByte(String s, int radix)
    Assuming the specified String represents a byte, returns that byte's value.
    Returns a String object representing this Byte's value.
    static Byte
    valueOf(byte i)
    Returns the object instance of i

    Methods inherited from class Number

    shortValue
    Modifier and Type
    Method
    Description
    short
     

    Methods inherited from class Object

    clone, getClass, notify, notifyAll, wait, wait, wait
    Modifier and Type
    Method
    Description
    protected Object
     
    final Class
    Returns the runtime class of an object.
    final void
    Wakes up a single thread that is waiting on this object's monitor.
    final void
    Wakes up all threads that are waiting on this object's monitor.
    final void
    Causes current thread to wait until another thread invokes the method or the method for this object.
    final void
    wait(long timeout)
    Causes current thread to wait until either another thread invokes the method or the method for this object, or a specified amount of time has elapsed.
    final void
    wait(long timeout, int nanos)
    Causes current thread to wait until another thread invokes the method or the method for this object, or some other thread interrupts the current thread, or a certain amount of real time has elapsed.
  • Field Details

    • TYPE

      public static final Class<Byte> TYPE
    • SIZE

      public static final int SIZE
      See Also:
    • MAX_VALUE

      public static final byte MAX_VALUE
      The maximum value a Byte can have. See Also:Constant Field Values
      See Also:
    • MIN_VALUE

      public static final byte MIN_VALUE
      The minimum value a Byte can have. See Also:Constant Field Values
      See Also:
  • Constructor Details

    • Byte

      public Byte(byte value)
      Constructs a Byte object initialized to the specified byte value. value - the initial value of the Byte
  • Method Details

    • byteValue

      public byte byteValue()
      Returns the value of this Byte as a byte.
      Overrides:
      byteValue in class Number
    • equals

      public boolean equals(Object obj)
      Compares this object to the specified object.
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Returns a hashcode for this Byte.
      Overrides:
      hashCode in class Object
    • parseByte

      public static byte parseByte(String s) throws NumberFormatException
      Assuming the specified String represents a byte, returns that byte's value. Throws an exception if the String cannot be parsed as a byte. The radix is assumed to be 10.
      Throws:
      NumberFormatException
    • parseByte

      public static byte parseByte(String s, int radix) throws NumberFormatException
      Assuming the specified String represents a byte, returns that byte's value. Throws an exception if the String cannot be parsed as a byte.
      Throws:
      NumberFormatException
    • toString

      public String toString()
      Returns a String object representing this Byte's value.
      Overrides:
      toString in class Object
    • valueOf

      public static Byte valueOf(byte i)
      Returns the object instance of i
      Parameters:
      i - the primitive
      Returns:
      object instance
    • intValue

      public int intValue()
      Specified by:
      intValue in class Number
    • longValue

      public long longValue()
      Specified by:
      longValue in class Number
    • floatValue

      public float floatValue()
      Specified by:
      floatValue in class Number
    • doubleValue

      public double doubleValue()
      Specified by:
      doubleValue in class Number
    • compare

      public int compare(byte b1, byte b2)
    • compareTo

      public int compareTo(Byte b)
      Description copied from interface: Comparable
      Compares this object to the specified object to determine their relative order.
      Specified by:
      compareTo in interface Comparable<Byte>
      Parameters:
      b - the object to compare to this instance.
      Returns:
      a negative integer if this instance is less than another; a positive integer if this instance is greater than another; 0 if this instance has the same order as another.