目录

void println(char[] x)

描述 (Description)

java.io.PrintWriter.println()方法打印一个字符数组,然后终止该行。 此方法的行为就像调用print(char [])然后调用println()一样。

声明 (Declaration)

以下是java.io.PrintWriter.println()方法的声明。

public void println(char[] x)

参数 (Parameters)

x - 要打印的字符数组。

返回值 (Return Value)

此方法不返回值。

异常 (Exception)

NA

例子 (Example)

以下示例显示了java.io.PrintWriter.println()方法的用法。

package com.iowiki;
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();
   }
}

让我们编译并运行上面的程序,这将产生以下结果 -

abcde
fghij
↑回到顶部↑
WIKI教程 @2018