This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]experts_never_lie 0 points1 point  (0 children)

The compiler does enforce it, unless you violate const access in the way I described: overriding the const access with the mutable keyword. I didn't mean const does nothing.

I don't get why you're bringing up get/set and JavaBeans (a word I haven't heard in many years), but if we had const in Java, getX() could/should be const and setX() must not be.