Java PrintStream.println(Object x)

Syntax

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

public void println(Object x)

Example

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


/*from  w  w  w . j a  va  2s. c o  m*/
import java.io.*;

public class Main {

   public static void main(String[] args) {
      Object c = 15;

      
      PrintStream ps = new PrintStream(System.out);

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

      // flush the stream
      ps.flush();

   }
}

The code above generates the following result.