当前位置: 代码迷 >> J2SE >> 看了早先的一个帖子protect变量不理解
  详细解决方案

看了早先的一个帖子protect变量不理解

热度:96   发布时间:2016-04-23 20:34:13.0
看了以前的一个帖子protect变量不理解
package com.chsxt.test;

public class TestAccess {
private int i = 9;
int j = 90;
protected int k = 92;
public int kk = 80;
}

package TestCsdn;

import com.chsxt.test.TestAccess;

public class Test4 extends TestAccess{
public static void main(String[] args){
TestAccess test = new TestAccess();
test.kk = 60;
test.k = 20;//为什么会报错,在TestAccess的子类中访问父类的protect变量为什么不可以?
}
}


------解决方案--------------------
java中protected的权限