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








Syntax

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

public void println(char x)

Example

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

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

public class Main {

   public static void main(String[] args) {
      char c = 'a';

      
      PrintStream ps = new PrintStream(System.out);

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

      // flush the stream
      ps.flush();

   }
}

The code above generates the following result.