Convert Java Integer object to Numeric primitive types - Java Language Basics

Java examples for Language Basics:Primitive Types

Introduction

  • Convert Integer to byte
  • Convert Integer to short
  • Convert Integer to int
  • Convert Integer to float
  • Convert Integer to double

Demo Code

 
public class Main {
 
  public static void main(String[] args) {
    Integer intObj = new Integer("10");
    byte b = intObj.byteValue();
    System.out.println(b);/*www . j a  v a  2 s .  c om*/
   
    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);
  }
}

Result


Related Tutorials