PrintWriter println() method in Java with Examples
Last Updated :
31 Jan, 2019
The println() method of PrintWriter Class in Java is used to break the line in the stream. This method do not accepts any parameter or return any value.
Syntax:
public void println()
Parameters: This method do not accepts any parameter.
Return : This method do not returns any value.
Below methods illustrates the working of println() method:
Program 1:
import java.io.*;
class GFG {
public static void main(String[] args)
{
try {
PrintWriter writer
= new PrintWriter(System.out);
writer.print( "GFG" );
writer.println();
writer.flush();
}
catch (Exception e) {
System.out.println(e);
}
}
}
|
Program 2:
import java.io.*;
class GFG {
public static void main(String[] args)
{
try {
PrintWriter writer
= new PrintWriter(System.out);
writer.print( 1.65 );
writer.println();
writer.flush();
}
catch (Exception e) {
System.out.println(e);
}
}
}
|
Share your thoughts in the comments
Please Login to comment...