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








Syntax

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

public void println(float x)

Example

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

//from  w  ww .j av a 2 s.  c  o  m
import java.io.*;

public class Main {

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

      
      PrintStream ps = new PrintStream(System.out);

      // print a float and change line
      ps.println(c);
      ps.print("from java2s.com");

      // flush the stream
      ps.flush();


   }
}

The code above generates the following result.