Open In App

PrintStream println(double) method in Java with Examples

Last Updated : 31 Jan, 2019
Improve
Improve
Like Article
Like
Save
Share
Report

The println(double) method of PrintStream Class in Java is used to print the specified double value on the stream and then break the line. This double value is taken as a parameter.

Syntax:

public void println(double doubleValue)

Parameters: This method accepts a mandatory parameter doubleValue which is the double value to be written on the stream.

Return Value: This method do not returns any value.

Below methods illustrates the working of println(double) method:

Program 1:




// Java program to demonstrate
// PrintStream println(double) method
  
import java.io.*;
  
class GFG {
    public static void main(String[] args)
    {
  
        try {
  
            // Create a PrintStream instance
            PrintStream stream
                = new PrintStream(System.out);
  
            // Print the double value '4.5'
            // to this stream using println() method
            // This will put the doubleValue in the
            // stream till it is printed on the console
            stream.println(4.5);
  
            stream.flush();
        }
        catch (Exception e) {
            System.out.println(e);
        }
    }
}


Output:

4.5

Program 2:




// Java program to demonstrate
// PrintStream println(double) method
  
import java.io.*;
  
class GFG {
    public static void main(String[] args)
    {
  
        try {
  
            // Create a PrintStream instance
            PrintStream stream
                = new PrintStream(System.out);
  
            // Print the double value '1.65'
            // to this stream using println() method
            // This will put the doubleValue in the
            // stream till it is printed on the console
            stream.println(1.65);
  
            stream.flush();
        }
        catch (Exception e) {
            System.out.println(e);
        }
    }
}


Output:

1.65


Similar Reads

PrintStream println(float) method in Java with Examples
The println(float) method of PrintStream Class in Java is used to print the specified float value on the stream and then break the line. This float value is taken as a parameter. Syntax: public void println(float floatValue) Parameters: This method accepts a mandatory parameter floatValue which is the float value to be written on the stream. Return
2 min read
PrintStream println(long) method in Java with Examples
The println(long) method of PrintStream Class in Java is used to print the specified long value on the stream and then break the line. This long value is taken as a parameter. Syntax: public void println(long longValue) Parameters: This method accepts a mandatory parameter longValue which is the long value to be written on the stream. Return Value:
2 min read
PrintStream println() method in Java with Examples
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
2 min read
PrintStream println(char[]) method in Java with Examples
The println(char[]) method of PrintStream Class in Java is used to print the specified character array on the stream and then break the line. This character array is taken as a parameter. Syntax: public void println(char[] charArray) Parameters: This method accepts a mandatory parameter charArray which is the character array to be printed in the St
2 min read
PrintStream println(int) method in Java with Examples
The println(int) method of PrintStream Class in Java is used to print the specified int value on the stream and then break the line. This int value is taken as a parameter. Syntax: public void println(int intValue) Parameters: This method accepts a mandatory parameter intValue which is the int value to be written on the stream. Return Value: This m
2 min read
PrintStream println(char) method in Java with Examples
The println(char) method of PrintStream Class in Java is used to print the specified char value on the stream and then break the line. This char value is taken as a parameter. Syntax: public void println(char charValue) Parameters: This method accepts a mandatory parameter charValue which is the char value to be written on the stream. Return Value:
2 min read
PrintStream println(boolean) method in Java with Examples
The println(boolean) method of PrintStream Class in Java is used to print the specified boolean value on the stream and then break the line. This boolean value is taken as a parameter. Syntax: public void println(boolean booleanValue) Parameters: This method accepts a mandatory parameter booleanValue which is the boolean value to be written on the
2 min read
PrintStream println(String) method in Java with Examples
The println(String) method of PrintStream Class in Java is used to print the specified String on the stream and then break the line. This String is taken as a parameter. Syntax: public void println(String string) Parameters: This method accepts a mandatory parameter string which is the String to be printed in the Stream. Return Value: This method d
2 min read
PrintStream println(Object) method in Java with Examples
The println(Object) method of PrintStream Class in Java is used to print the specified Object on the stream and then break the line. This Object is taken as a parameter. Syntax: public void println(Object object) Parameters: This method accepts a mandatory parameter object which is the Object to be printed in the Stream. Return Value: This method d
2 min read
Difference Between System.out.println() and System.err.println() in Java
System.out is a PrintStream to which we can write characters. It outputs the data we write to it on the Command Line Interface console/terminal. It is mostly used for console applications/programs to display the result to the user. It can be also useful in debugging small programs. Syntax: System.out.println("Your Text which you want to display");
2 min read
Practice Tags :