Java private field access

Java private field access.


public class PrivateFieldsAccess {
    private String name;
    private Integer age;

    public PrivateFieldsAccess(String name, Integer age) { = name;
        this.age = age;

    public int compare(PrivateFieldsAccess other) {
        // private fields can be accessed within the class itself
        // even when the private fields belong to other instances
        return this.age.compareTo(other.age);