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








Syntax

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

public void println(int x)

Example

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

import java.io.*;
/*from  w  w w. j  a v  a 2  s.  c  om*/
public class Main {

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

      
      PrintStream ps = new PrintStream(System.out);

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

      // flush the stream
      ps.flush();


   }
}

The code above generates the following result.