Protected access modifier in Java

后端 未结 4 1984
温柔的废话
温柔的废话 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:49

    protected means visibile to other classes within the same package. since Second is in a different package 'second.Second', it cannot access .pro() in first.

    if you created Second under the package name of 'first' - it would then work.

提交回复
热议问题