Slide 50
Slide 50 text
@CGuntur
Algebraic Data Types - Records
• Introduction of algebraic data types into Java, with records
• Immutable data objects with built in constructors and accessors
record Range(int lo, int hi) {
public Range {
if (lo > hi) /* referring here to the implicit constructor parameters */
throw new IllegalArgumentException(String.format("(%d,%d)", lo, hi));
}
}
• JEP 359 - Records (Preview):
https://openjdk.java.net/jeps/359
50
Java 14
P