Java Record
Records are immutable data classes that require only the type and name of fields. :
public record Student(String name, int division) {}
领英推荐
public record Student(String name, int division) { public String greet() { return "Name of the student is " + name + " and is in division " + division; }. }
import com.fasterxml.jackson.databind.ObjectMapper;
ObjectMapper mapper = new ObjectMapper(); String jsonString = mapper.writeValueAsString(new Student("Alice", 10));