-
constant methods in Java
Is there something in Java analagous to C++'s constant member functions?
On first glance, it seems like Java offers no protection for classes (other than immutable classes which I don't think is the same thing). A constant reference to an object in C++ allows only access to constant methods. In Java, a constant reference to an object means something entirely different - the reference itself cannot be changed (ie point to a different instance of the class).
Well, how do you protect your classes in Java then? Is there a way to specify constant methods VS mutator methods like in C++, or is there something else?