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








Syntax

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

public void println(int x)

Example

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

/*w  ww . java 2  s . c o m*/
import java.io.*;

public class Main {

   public static void main(String[] args) {
      int i = 123;

      
      PrintWriter pw = new PrintWriter(System.out);

      // print int
      pw.println(i);
      pw.println(987);

      // flush the writer
      pw.flush();

   }
}

The code above generates the following result.