sgokhales sgokhales - 1 month ago 18
Java Question

Access Specifier for Interface Declaration

Why protected/private access specifier cannot be used Interfaces declaration ?

Answer

You can declare a protected class or indeed a private one - but only within another one. At that point it's either visible to classes derived from the outer one (in the case of protected) or not (in the case of private):

public class Outer
{
    private static class NotVisibleToSubclassesOfOuter {}

    protected static class VisibleToSubclassesOfOuter {}
}