Use Float constructor to convert float primitive type to a Float object in Java

Description

The following code shows how to use Float constructor to convert float primitive type to a Float object.

Example


// ww  w .j  a  v a 2  s  . c om
public class Main {

  public static void main(String[] args) {
    float f = 10.56f;
    Float fObj = new Float(f);
    System.out.println(fObj);
  }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    Reflection »




Annotation
Array
Class
Constructor
Field
Generics
Interface
Method
Modifier
Package
Proxy