Class Byte

java.lang.Object
java.lang.Number
java.lang.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 java.lang.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
    equals(java.lang.Object obj)
    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

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • TYPE

      public static final java.lang.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(java.lang.Object obj)
      Compares this object to the specified object.
      Overrides:
      equals in class java.lang.Object
    • hashCode

      public int hashCode()
      Returns a hashcode for this Byte.
      Overrides:
      hashCode in class java.lang.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 java.lang.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.

      Parameters
      • another: the object to compare to this instance.
      Returns
      Specified by:
      compareTo in interface Comparable<Byte>
      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.

      Throws
      • ClassCastException: @throws ClassCastException if another cannot be converted into something comparable to this instance.