Java Data Type Tutorial - Java Float(String s) Constructor








Syntax

Float(String s) constructor from Float has the following syntax.

public Float(String s)  throws NumberFormatException

Example

In the following code shows how to use Float.Float(String s) constructor.

public class Main {
  public static void main(String[] args) {

    Float float3 = new Float("0.2");
    
    System.out.println(float3);
    
  }
}

The output: