PrintWriter.print(float f) has the following syntax.
public void print(float f)
In the following code shows how to use PrintWriter.print(float f) method.
/* www. j a v a 2s.co m*/ import java.io.*; public class Main { public static void main(String[] args) { float f = 1234.56f; PrintWriter pw = new PrintWriter(System.out); // print float pw.print(f); // change the line pw.println(); // print another float pw.print(1.23f); // flush the writer pw.flush(); } }
The code above generates the following result.