public methods in package-private classes

后端 未结 7 1646
刺人心
刺人心 2020-12-04 19:35

Does it make a difference to mark methods as public in package-private classes?

class SomePackagePrivateClass
{
    void foo();          // pack         


        
7条回答
  •  半阙折子戏
    2020-12-04 19:56

    Another case where the method has to be public is when you are creating a package private implementation of some public class or interface. Since you are not allowed to reduce the visibility of overridden methods, these have to be public.

提交回复
热议问题