Can someone explain to me in detail the solution to this answer? I am not 100% sure how Java ensures that this will not be done.
Q. What is the biggest difference between a parameter of a primitive type and a parameter of a class type?
The biggest difference is in how a method handles arguments that correspond to the different kinds of parameters. A method cannot change the value of a variable of a primitive type that is an argument to the method, nor can it replace an argument of a class type with another object. On the other hand, a method can change the values of an object of a class type whose name is an argument to the method.