Getter for private instance attributes



examples/getter/TryPoint.java
public class TryPoint {
    public static void main(String[] args) {
        Point a = new Point(7, 3);
        System.out.println(a.getX());
    }
}

examples/getter/Point.java
public class Point {
    private int x;
    private int y;
    public Point(int x, int y) {
        this.x = x;
        this.y = y;

    }

    public int getX() {
        return this.x;
    }
}