Not sure this helps but this is the first thing that comes to mind.
the example below wont allow modification of s.
If you did:
String x = ConstTest.getStr();
x = "Xyz";
ConstTest's private value wouldn't be altered.
This is the common rule: you can ONLY alter objects by calling methods on
them. Not by changing them via the = sign. If we could do:
x.setValue("Xyz");
we'd change the internal object in ConstTest. (Part from the fact that
Strings still are returned by value in java, not by reference. at least I
think so...)
On the opposite: To make it possible to return a string that, when altered
would affect the object in ConstTest you'd need to use StringBuffer instead.
(Or wrap your string in another object that you use getters and setters on).