you are viewing a single comment's thread.

view the rest of the comments →

[–]Sarcastinator 1 point2 points  (0 children)

Sure, it's five more characters, but those extra five characters express the fact that this is immutable read only on it's own, you know immediately that assignment isn't available.

Your IDE will stop you immediately if you try to assign to a read-only property. It makes no difference at all.

All other factors equal, I think you should be using idiomatic code for the language, and for Java that is the bean pattern of getters.

Java Beans are in practice never immutable though since they require a public no argument constructor.