我是初学者,编写了如下代码,在两个包里面。
第一个包是父类的:
package Study;public class Parent {
 
private int i;
int j;
protected int m;
public int n;}
第二个包是子类的:
package Study.Study;
import Study.*;
class Child3 extends Parent{}
public class Child2 extends Parent{
 
 
 
 public static void main(String[] args) {
  
Child3 x=new Child3();
x.m=1;
Child2 y=new Child2();
y.m=2;
  
 }y.m=2可以访问
但是为什么 x.m=1就不可以访问不是说protected在不同的包里面也能访问吗。
y.m和x.m都和原来的父类不在一个包里面,怎么一个可以访问,一个不可以访问。