Declaration
To declare a record you write the word record
followed by a
class name, a list of "record components" in parentheses, and a pair of {}
.
The list of record components should be reminiscent of function arguments.
record Person(String name, int age) {}
Having an empty list of record components is also allowed.1
record Pants() {}
1
As to why you might want to give an empty list of record components, its nuanced. For now its just for fun.