Java PrintStream.println()
Syntax
PrintStream.println() has the following syntax.
public void println()
Example
In the following code shows how to use PrintStream.println() method.
/*from w ww .jav a 2 s . c o m*/
import java.io.*;
public class Main {
public static void main(String[] args) {
PrintStream ps = new PrintStream(System.out);
// print this string
ps.print("This is a String");
// print new line
ps.println();
// print a new string
ps.println("from java2s.com");
// flush the stream
ps.flush();
}
}
The code above generates the following result.
Home »
Java Tutorial »
java.io »
Java Tutorial »
java.io »