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








Syntax

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

public void println(double x)

Example

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

//from ww w .  ja  v a2  s.c  om
import java.io.*;

public class Main {

   public static void main(String[] args) {
      double d = 123.456;

      
      PrintWriter pw = new PrintWriter(System.out);

      // print doubles
      pw.println(d);
      pw.println(987.765);

      // flush the writer
      pw.flush();

   }
}

The code above generates the following result.