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








Syntax

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

public void print(char c)

Example

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

/*from  w ww  . jav  a2s. 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 char
      ps.print(c);
      ps.print('b');

      // flush the stream
      ps.flush();

   }
}

The code above generates the following result.