2 ms·
> The job of a constructor is to establish the class’s invariants for the new instance, or else fail with an exception. Could you refer such statement in Java
by ris58h 3y ago
> The job of a constructor is to establish the class’s invariants for the new instance, or else fail with an exception.
Could you refer such statement in Java specification?
- jdmichal 3y agoInvariants and all methods -- including constructors -- enforcing them is OOP 101. I would be surprised if they felt the need to make such a callout in the language specification.