모던 Java 코드 스니펫 모음. 오래된 Java 패턴과 깔끔하고 모던한 대체 코드를 나란히 비교합니다.
public class Point {
private final int x, y;
public Point(int x, int y) { ... }
public int getX() { return x; }
public int getY() { return y; }
// equals, hashCode, toString
}
public record Point(int x, int y) {}