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

ReturnMethodSummary
bytebyteValue()Returns the value of this Short as a byte.
doubledoubleValue()Returns the value of this Short as a double.
floatfloatValue()Returns the value of this Short as a float.
intintValue()Returns the value of this Short as an int.
longlongValue()Returns the value of this Short as a long.
shortshortValue()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
java2s.com  |  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.