Java IO Tutorial - Java PrintStream.print(float f)








Syntax

PrintStream.print(float f) has the following syntax.

public void print(float f)

Example

In the following code shows how to use PrintStream.print(float f) method.

//from   w w w  .j  a va2  s  .co  m
import java.io.*;

public class Main {

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

      
      PrintStream ps = new PrintStream(System.out);

      // print float
      ps.print(x);

      // flush the stream
      ps.flush();

   }
}

The code above generates the following result.