Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

java record

// create immutable record added in jdk 14
// provides all-args constructor, getters, equals, hashcode and toString
public record Person (String name, String address) {}

// usage
Person person = new Person("John Doe", "100 Linda Ln.");

// access fields
String name = person.name();
String address = person.address();
Source by www.baeldung.com #
 
PREVIOUS NEXT
Tagged: #java #record
ADD COMMENT
Topic
Name
6+5 =