Java PrintStream.println(String x)

Syntax

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

public void println(String x)

Example

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


//  w w w  .  j  a va  2 s.co  m
import java.io.*;

public class Main {

   public static void main(String[] args) {
      String c = "from java2s.com";

      
      PrintStream ps = new PrintStream(System.out);

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

      // flush the stream
      ps.flush();

   }
}

The code above generates the following result.