Class FlexibleConstructorBodiesExamples
java.lang.Object
net.jrodolfo.java_evolution.java25.FlexibleConstructorBodiesExamples
Demonstrates flexible constructor bodies, finalized in Java 25.
Older Java syntax required an explicit constructor invocation to be the first statement. That made validation before delegation awkward. Flexible constructor bodies let constructors perform safe validation or preparation before invoking another constructor, while still preventing unsafe use of the object under construction.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classSimple account model used to demonstrate validation before constructor delegation. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionCreates a validated account.
-
Constructor Details
-
FlexibleConstructorBodiesExamples
public FlexibleConstructorBodiesExamples()
-
-
Method Details
-
account
Creates a validated account.- Parameters:
owner- account owner- Returns:
- account object
-