Java printwriter类的println ()方法用于中断的行。 此方法不接受参数或返回值。
使用方法:
公共语音打印机(
参数:此方法不接受参数。
返回:此方法不返回值。
以下方法说明了如何使用println ) )方法。
样本1:
//Java程序到演示
//PrintWriter println () method
import java.io.*;
class GFG {
publicstaticvoidmain (字符串[ ] args ) )。
{
try {
//create a打印机实例
打印机写入器
=new printwriter (系统. out;
//Print the value 'GFG '
//to this stream using print () method
//This will put the in the
//streamtillitisprintedontheconsole
writer.print(gfg );
//Break the line in the stream
//using println () method
writer.println (;
writer.flush (;
}
catch(exceptione ) {
系统. out.println (e;
}
}
}
输出:
GFG
样本2:
//Java程序到演示
//PrintWriter println () method
import java.io.*;
class GFG {
publicstaticvoidmain (字符串[ ] args ) )。
{
try {
//create a打印机实例
打印机写入器
=new printwriter (系统. out;
//Print the value '1.65 '
//to this stream using print () method
//This will put the in the
//streamtillitisprintedontheconsole
writer.print(1.65;
//Break the line in the stream
//using println () method
writer.println (;
writer.flush (;
}
catch(exceptione ) {
系统. out.println (e;
}
}
}
输出:
1.65