Why can I access a variable with private access without a getter (colour == ((ColouredPoint) other).colour
)? Here is the code for my ColouredPoint
class:
public class ColouredPoint extends Point {
private Colour colour;
public ColouredPoint(double x, double y, double z, Colour colour) {
super(x, y, z);
this.colour = colour;
}
@Override
public String toString() {
return "(" + super.toString() + ", " + colour + ")";
}
@Override
public boolean equals(Object other) {
if (other instanceof ColouredPoint) {
return x == ((ColouredPoint) other).x
&& y == ((ColouredPoint) other).y
&& z == ((ColouredPoint) other).z
&& colour == ((ColouredPoint) other).colour;
}
return false;
}
}