Create a Float object

ConstructorSummary
Float(double value)Creates a Float object from double-type value and convert it to type float.
Float(float value)Creates a Float object for the primitive float argument.
Float(String s)Creates a Float object that represents the floating-point value of type float represented by the string.

public class Main {
  public static void main(String[] args) {
    Float float1 = new Float(0.0d);
    Float float2 = new Float(0.1F);
    Float float3 = new Float("0.2");
    
    System.out.println(float1);
    System.out.println(float2);
    System.out.println(float3);
    
  }
}

The output:


0.0
0.1
0.2
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.