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








Syntax

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

public void println(char x)

Example

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

import java.io.*;
/*www .  j  a v  a2  s  .c  o  m*/
public class Main {

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

      
      PrintWriter pw = new PrintWriter(System.out);

      // print string
      pw.println(c);
      pw.println('b');

      // flush the writer
      pw.flush();

   }
}

The code above generates the following result.