Convert Short to byte, double, float, int, long and short

byte byteValue()
Returns the value of this Short as a byte.
double doubleValue()
Returns the value of this Short as a double.
float floatValue()
Returns the value of this Short as a float.
int intValue()
Returns the value of this Short as an int.
long longValue()
Returns the value of this Short as a long.
short shortValue()
Returns the value of this Short as a short.

public class Main {
  public static void main(String[] args) {
    Short shortObject = new Short("10");
    byte b = shortObject.byteValue();
    System.out.println("byte:"+b);

    short s = shortObject.shortValue();
    System.out.println("short:"+s);

    int i = shortObject.intValue();
    System.out.println("int:"+i);

    float f = shortObject.floatValue();
    System.out.println("float"+f);

    double d = shortObject.doubleValue();
    System.out.println("double:"+d);

    long l = shortObject.longValue();
    System.out.println("long:"+l);
  }
}

The output:


byte:10
short:10
int:10
float10.0
double:10.0
long:10
Home 
  Java Book 
    Essential Classes  

Short:
  1. Short class
  2. Find out the min value, max value and size of Short types
  3. Create Short object with its constructor
  4. Convert Short to byte, double, float, int, long and short
  5. Decode a string to short value
  6. Convert string to a short value
  7. Reverse the bytes in a short
  8. Convert short value to string
  9. Compare two short values