Protected member access from different packages in java - a curiosity [duplicate]
This question already has an answer here: Understanding java's protected modifier 6 answers package packageOne; public class Base { protected void display(){ System.out.println("in Base"); } } package packageTwo; public class Derived extends packageOne.Base { public void show(){ new Base().display(); //this is not working throws compilation error that display() from the type Base is not visible new Derived().display(); //is working display(); //is working } } The two packages are in two different files. But why this behaviour? irreputable http://java.sun.com/docs/books/jls/third_edition/html