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.

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

public class Main {

   public static void main(String[] args) {
      char[] c1 = {'a', 'b', 'c', 'd', 'e'};
      char[] c2 = {'f', 'g', 'h', 'i', 'j'};

      
      PrintWriter pw = new PrintWriter(System.out);

      // print char array
      pw.println(c1);
      pw.println(c2);

      // flush the writer
      pw.flush();

   }
}

The code above generates the following result.