Custom Canonical constructor in Record

In the previous post under Java Record, I mentioned how the compiler creates a long (canonical) constructor automatically. In this post, I will explain how to create a custom canonical constructor. Now why we need to provide a custom canonical constructor when it is already provided by compiler. The canonical constructor created by compiler will…… Continue reading Custom Canonical constructor in Record

Adding and accessing static members to Java Record

In this post under Java, I will show with example how to add and access static members in Java Record. Below is the structure of “Student” Record with static members Student 1 package core.record;2 3 public record Student(int id, String name, int age) {4 public static int noOfStudents;5 public static void display() {6 System.out.println(“Number of…… Continue reading Adding and accessing static members to Java Record