You can add final to the parameter, but this will only prevent their initialization, you can still call the method and setter, changing the contents of your Vector .
If you need to restrict access to them, you may need to create an immutable class that hides the Vector wrapper . Basically, it redirects only those methods that prevent any update, hiding the installer and restricting getter to primitive values, returning an instance, makes it possible to change the value in it.
Of course, there is some decisive solution, you can clone a vector and its content. Saving instances is safe, even if someone is trying to update some values. This will only be a problem during this call, using the wrong values, but will keep the original instances intact.
Or you could use both solutions by creating a wrapper that returns the cloned instance (you just need to provide get (int index), which returns the clone). This solution is a compromise between memory consumption (cloning only the required instance) and restrictive getter.
Axelh source share