Double.valueOf() double in Java

Double.valueOf(): This method is available in java.lang.Double class of Java.

Syntax:

Double java.lang.Double.valueOf(double d)

This method takes one argument of type double as its parameter. This method returns a Double instance representing the specified double value.

Parameters: One parameter is required for this method.

d: a double value.

Returns: a Double instance representing d.

For Example:

double d = 188.7

Double.valueOf(d) = > It returns 188.7

Approach

Java

public class DoubleValueofDouble {
    public static void main(String[] args) {

        double d = 188.7;
        System.out.println(Double.valueOf(d));

    }
}

Output:

188.7

No comments:

Post a Comment