233k views
5 votes
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.

User Remigio
by
4.9k points

1 Answer

6 votes

Answer:

Double newMyDouble = new Double(x);

myDouble = newMyDouble2;

Step-by-step explanation:

Here the new object newMyDouble is firstly the initial value of said 'double x'. In the second line myDouble is the reassigned the the newMyDouble, which is in fact, the value of x. This exercise helps you understand the syntax of using reference variables in JAVA and their assignment along with reassignment.

User Nijo
by
5.3k points