Java.io.PrintWriter.println() Method
Advertisements
Description
The java.io.PrintWriter.println() method prints an array of characters and then terminates the line. This method behaves as though it invokes print(char[]) and then println().
Declaration
Following is the declaration for java.io.PrintWriter.println() method
public void println(char[] x)
Parameters
x -- the array of chars to be printed
Return Value
This method does not return a value.
Exception
NA
Example
The following example shows the usage of java.io.PrintWriter.println() method.
package com.tutorialspoint;
import java.io.*;
public class PrintWriterDemo {
public static void main(String[] args) {
char[] c1 = {'a', 'b', 'c', 'd', 'e'};
char[] c2 = {'f', 'g', 'h', 'i', 'j'};
// create a new writer
PrintWriter pw = new PrintWriter(System.out);
// print char array
pw.println(c1);
pw.println(c2);
// flush the writer
pw.flush();
}
}
Let us compile and run the above program, this will produce the following result:
abcde fghij