Protected access modifier in Java

后端 未结 4 2007
温柔的废话
温柔的废话 2020-11-30 07:56

I am having a little trouble understanding the protected access modifier in java (or the design behind it). I thought it meant package access and access through objects that

4条回答
  •  生来不讨喜
    2020-11-30 08:55

    protected vs. defaultHere is a diagram to show the access level. You code belongs to the R(Reference) case in Convertible in the diagram. That is, reference in subclass in another package is not allowed to access.

提交回复
热议问题