8
有人可以告訴我有關私人會員的訪問級別嗎?我很長時間以來對這段代碼感到困惑:爲什麼可以使用outter類的「print」方法訪問Line類的私有成員k?爲什麼可以通過封閉類的方法訪問嵌套類的私有成員?
public class myClass {
public static class Line{
private double k;
private double b;
private boolean isVertical;
public Line(double k, double b, boolean isVertical){
this.k = k;
this.b = b;
this.isVertical = isVertical;
}
}
public static boolean print(Line line){
System.out.println(line.k);
}
}