Why can't my subclass access a protected variable of its superclass, when it's in a different package?

前端 未结 4 1498
梦谈多话
梦谈多话 2020-11-29 05:55

I have an abstract class, relation in package database.relation and a subclass of it, Join, in package database.operations

4条回答
  •  有刺的猬
    2020-11-29 06:28

    If protected, your instance of Join cannot access the mStructure in other instances (relRight, relLeft) outside the package.

    EDIT:

    The table here explains this situation fairly well. I marked the culprit in your question with []s

    Access Levels
    Modifier    Class Package Subclass  World
    public      Y     Y       Y         Y
    protected   Y    [Y]      Y         N
    no modifier Y     Y       N         N
    private     Y     N       N         N
    

提交回复
热议问题