Create an object of type Double with the initial value of x and assign it to the reference variable myDouble.

Create an object of type Double with the initial value of x and assign it to the reference variable myDouble.

LANGUAGE:  JAVA

CHALLENGE:

Suppose a reference variable of type Double called myDouble has already been declared.
There is also a double variable x that has been declared and initialized.
Create an object of type Double with the initial value of x and assign it to the reference variable myDouble.

SOLUTION:


Double myDouble2 = new Double(x);
myDouble = myDouble2;

Add comment