Re:Data Classes for Java
by opmac on Wednesday November 01, 2017 @07:42PM
(#15606540)
Just use public final. That is the defacto way to make immutable data classes. Why would a data class need non final fields?
[ Parent
| on HN ]
Re:Data Classes for Java
by arthur_pryor on Wednesday November 01, 2017 @08:51PM
(#15606923)
i'm a little rusty on my java, but i don't think this will work for non-constants (i.e. it won't work for things you don't set at compile time).
to my knowledge, there's no "make this a constant after the first time the value is set" declaration in java (or any language that i'm aware of).