Member-only story
Java-14 Features
Record Keyword in Java 14
Get rid of boilerplate code.
We write classes that are simply POJO or beans or models that have some fields and their getters and setters along with toString(), hashCode() and equals() methods are overridden to provide good class definitions. These classes are used as transferrable beans between different modules of the application.
Sometimes, these types of POJO classes tend to be immutable which means once the object of these classes is created their object’s fields cannot be modified or changed.
Writing these POJOs is tedious and has many lines of boilerplate code if we have to write multiple classes then for each class we have to repeat the same process.
An example of a Person POJO class is as below:
package com.basecs101.model;
import java.util.Objects;
/**
* A simple POJO clas with 3 fields
*/
public class Person {
private String firstName;
private String lastName;
private int age;
public Person(String firstName, String lastName, int age) {
this.firstName = firstName;
this.lastName = lastName;
this.age = age;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {…









