Convert Java Float to Numeric Primitive Data Types - Java Language Basics

Java examples for Language Basics:float

Description

Convert Java Float to Numeric Primitive Data Types

Demo Code


public class Main {
 
  public static void main(String[] args) {
 
    Float fObj = new Float("10.50");
    byte b = fObj.byteValue();
    System.out.println(b);//w w w  .jav a 2s .  c o m
   
    short s = fObj.shortValue();
    System.out.println(s);
   
    int i = fObj.intValue();
    System.out.println(i);
   
    float f = fObj.floatValue();
    System.out.println(f);
 
    double d = fObj.doubleValue();
    System.out.println(d);
 
  }
}

Result


Related Tutorials