java中的protected提供package访问权限

  也就是,从它们的私有性来说,依次是:private,package,protected(也提供给包以外的继承类访问),public

  摘自:Thinking in Java, 3rd ed. Revision 4.0 6: Reusing Classes protected

 It says “This is private as far as the class user is concerned, but available to anyone who inherits from this class or anyone else in the same package.” (In Java, protected also provides package access.)

  另外,因为abstract方法必须被它的继承类实现才有意义,所以它至少要提供package访问,按道理来说,应该提供protected访问,因为这样可以供在包外的继承者来实现它。