(no title)
_old_dude_ | 10 months ago
static final Complex CONSTANT = new Complex(1, 2);
If you want a lazy initialized constant, you want a stable value static final StableValue<Complex> STABLE_VALUE = StableValue.of();
Complex getLazyConstant() {
return STABLE_VALUE.orElseGet(() -> new Complex(1, 2))
}
If you want the fields of a constant to be constant too, Complex has to be declared has a record.
No comments yet.