Java IO Tutorial - Java PrintWriter.print(char c)








Syntax

PrintWriter.print(char c) has the following syntax.

public void print(char c)

Example

In the following code shows how to use PrintWriter.print(char c) method.

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

public class Main {

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

      
      PrintWriter pw = new PrintWriter(System.out);

      // print chars
      pw.print(c);

      // change line
      pw.println();

      // print another char
      pw.print('b');

      // flush the writer
      pw.flush();

   }
}

The code above generates the following result.