How do I create a reference to a constant object?
final Myclass obj = new Myclass();
does not work, it says obj(the reference) should not be re-assigned but we can still change the object referred.
I want to ensure that the object itself does not change once constructed.
Just make it immutable (like
Stringis). Or wrap it in another object which restricts access to mutators of the object in question (likeCollections.unmodifiableList()and consorts do).