6.6.3 An Example of Access Control

For examples of access control, consider the two compilation units:


package points;
class PointVec { Point[] vec; }

and:


package points;


public class Point {
	protected int x, y;
	public void move(int dx, int dy) { x += dx; y += dy; }
	public int getX() { return x; }
	public int getY() { return y; }
}

which declare two class types in the package points:

See §6.6.7 for an example of how the protected access modifier limits access.