When we use classes in Java it's very simple to add JavaDoc/comment for each class field/method:
class Product {
//Product unique identifier
private int id;
}
If we migrate these classes to Java records then it's unclear what is the the best practice to write comments/JavaDocs in this case:
record Product(int id, String name, double price) {
}
Because now all the fields are declared in one line.
Well, you have two choices concerning documentation, either use the Javadoc on record level, or use a block comment, I've used both hereunder
Here is an example of Javadoc from the JDK itself
And here is an example with a comment block (even though it does not have any parameter)