Java.lang.Double.valueOf(double d) Method


Advertisements


Description

The java.lang.Double.valueOf(double d) method returns a Double instance representing the specified double value d.

Declaration

Following is the declaration for java.lang.Double.valueOf() method

public static Double valueOf(double d)

Parameters

d − This is the double value.

Return Value

This method returns a a Double instance representing d.

Exception

NA

Example

The following example shows the usage of java.lang.Double.valueOf() method.

package com.tutorialspoint;

import java.lang.*;

public class DoubleDemo {

   public static void main(String[] args) {

      Double d1 = new Double("6.5");
   
      // returns a Double instance representing the specified double value 
      System.out.println("Value = " +  d1.valueOf(3.5d));
   }
} 

Let us compile and run the above program, this will produce the following result −

Value = 3.5

java_lang_double.htm

Advertisements