Return an integer value as byte, double, float, int, long and short

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

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

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

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

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

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

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

The output:


byte:-121
short:-10617
int:1234567
float1234567.0
double:1234567.0
long:1234567
Home 
  Java Book 
    Essential Classes  

Integer:
  1. Integer class
  2. Max, min value of an integer type variable
  3. Create Integer using its constructors
  4. Return an integer value as byte, double, float, int, long and short
  5. Compare two integer values
  6. Decode a string and return an integer value
  7. Convert string to integer
  8. Convert integer to string
  9. Reverse and rotate the integer in binary format
  10. Bit oriented operation
  11. Return system property as integer
  12. Get the leading and trailing zeros
  13. Get the sign of an Integer
  14. Convert integer to binary, hexdecimal and octal format