Java IO Tutorial - Java PrintWriter.println(float x)








Syntax

PrintWriter.println(float x) has the following syntax.

public void println(float x)

Example

In the following code shows how to use PrintWriter.println(float x) method.

//w w  w . ja  v  a 2s. c o  m
import java.io.*;

public class Main {

   public static void main(String[] args) {
      float f = 123.456f;

      
      PrintWriter pw = new PrintWriter(System.out);

      // print float
      pw.println(f);
      pw.println(987.765f);

      // flush the writer
      pw.flush();

   }
}

The code above generates the following result.