Convert Java Integer object to Numeric primitive types : Primitive Data Type « Data Type « Java






Convert Java Integer object to Numeric primitive types

     

public class Main {

  public static void main(String[] args) {
    Integer intObj = new Integer("10");
    byte b = intObj.byteValue();
    System.out.println(b);

    short s = intObj.shortValue();
    System.out.println(s);

    int i = intObj.intValue();
    System.out.println(i);

    float f = intObj.floatValue();
    System.out.println(f);

    double d = intObj.doubleValue();
    System.out.println(d);
  }
}

   
    
    
    
    
  








Related examples in the same category

1.Use Integer constructor to convert int primitive type to Integer object.
2.Convert Java String to Integer object
3.Create an Integer object
4.Arithmetic DemoArithmetic Demo
5.Max Variable Length DemoMax Variable Length Demo
6.Data Type Print TestData Type Print Test
7.Tests all the operators on all the primitive data types
8.Demonstrates the ++ and -- operatorsDemonstrates the ++ and -- operators
9.Literals
10.Demonstrates the mathematical operators.Demonstrates the mathematical operators.
11.Java lets you overflowJava lets you overflow
12.Built in typesBuilt in types
13.Shows default initial valuesShows default initial values
14.Relational DemoRelational Demo
15.Parse Number
16.Java Type Helper
17.Convert the given array (which may be a primitive array) to an object array
18.Convert primitive back and forth
19.Returns a default value if the object passed is null
20.A mutable boolean wrapper.
21.A mutable byte wrapper.
22.A mutable double wrapper.
23.A mutable float wrapper.
24.A mutable int wrapper.
25.A mutable long wrapper.
26.A mutable short wrapper.
27.Primitive utilities