I need a small Container-Class for storing some Strings which should be immutable. As String itself is an immutable type, I thought of something like that:
p
I found this thread hoping for some actual arguments, but the answers I've seen here didn't help me all that much. After some more research and thinking I think the following has to be considered:
public final looks cleanest for immutable types.public final clearly tells the programmer that no hidden magic is occuring and the object is inherently dumb :)If you're mid development and no guideline is stopping you and the project is isolated or you have control over all involved projects I'd suggest using public final for immutable types. If you decide you need getters later on, Eclipse offers Refactor -> Encapsulate Field... which automatically creates these and adjusts all references to the field.