Question: Java 14 introduces a syntactic sugar called a record. It's a short-hand notion for creating an immutable class that provides boilerplate code for a constructor,
Java 14 introduces a syntactic sugar called a record. It's a short-hand notion for creating an immutable class that provides boilerplate code for a constructor, getters, equals(), hashCode(), and toString() methods. Write a plain Jave class equivalent to the Place record below public record Place (int x, int y ) } II Example use. Place p = new Place (10,20); System out println (px()+","+py()); Systom.out printin(p.equals(new Place (10,20)). Systom out printin(p hash Code()). System out printin(p); Il tostring 0 is called Submit source code file and screenshots of sample runs
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
