PrintStream println() method in Java with Examples
Last Updated :
31 Jan, 2019
The println() method of PrintStream 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 {
PrintStream stream
= new PrintStream(System.out);
stream.print( "GFG" );
stream.println();
stream.flush();
}
catch (Exception e) {
System.out.println(e);
}
}
}
|
Program 2:
import java.io.*;
class GFG {
public static void main(String[] args)
{
try {
PrintStream stream
= new PrintStream(System.out);
stream.print( 1.65 );
stream.println();
stream.flush();
}
catch (Exception e) {
System.out.println(e);
}
}
}
|
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...