Setter for private instance attributes



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

    }
}

examples/setter/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;
    }

    public void setX(int x) {
        this.x = x;

    }
}