class Box {
double width;
double height;
double depth;
double vol;
public Box(final Box box) {
this.width = box.width;
this.height = box.height;
this.depth = box.depth;
box.vol += 10_000;
}
You see I was creating an class called Box, and I have overloaded the construction. I realized that using final
keyword to stop the parameter being assigned, but it cannot stop the parameter to change its' parameters.
So I was wondering if there is a way to stop this constructing function changing the parameter's attribute?