Working with immutable objects in JShell
The following lines create a new ImmutableVector3d
instance named vector10
with 100.0
, 200.0
, and 300.0
for the initial values of x
, y
, and z
. The second lines create a new ImmutableVector3d
instance named vector20
with 11.0
, 12.0
, and 13.0
for the initial values of x
, y
, and z
. Then, the code calls the System.out.println
method with vector10
and then with vector20
as an argument. Both calls to the println
method will execute the toString
method for each ImmutableVector3d
instance to display the String
representation of the immutable 3D vector. Then, the code calls the add
method for vector10
with vector20
as an argument and saves the returned ImmutableVector3d
instance in vector30
.
The last line calls the println
method with vector30
as an argument to print the values of x
, y
, and z
for this instance that has the results of the addition operation between vector10
and vector20
. Enter the lines after the code that declares the ImmutableVector3d
class...