:관련없는 클래스에서는 어떻게 보호 된 메서드에 액세스 할 수 있습니까?
public interface X
{
final public static int SOME_CONST = 0;
}
public class Handle implements X
{
protected void methodHandle() { }
//...
}
public class User implements X
{
Handle handle = new Handle();
private void methodUser()
{
Y y = new Y() // anonymous inner class
{
public void methodY()
{
handle.methodHandle(); // <--- why this is NOT giving error ?
}
}
}
}
에도 Handle.methodHandle()
생각은 익명의 내부 class
방법의 내부 방법에서 여전히 호출입니다, protected
입니까? 왜 그런 일이 일어나고있는 것일까? Handle
과 User
사이의 유일한 관계는 implement
ing same X
입니다.
+1 그래, 그들은 실제로 "무관"하지 않습니다. – iammilind