JLS 8.10.4. Record Constructor Declarations says:You may provide any number of constructors in a record. However,
1. if you provide a non-canonical constructor, you must also provide a canonical constructor (because the compiler will not provide it automatically now)
Can't you compile a record class with non-canonical constructor and no explicitly declared canonical constructor as following?If a canonical constructor is not explicitly declared in the declaration of a record class R, then a canonical constructor r is implicitly declared in R with the following properties:...
Code: Select all
public record Student(int id, String name){
public Student(){ //non-canonical constructor
this(10, "");
}
}