package cn.test.testAccess;
public class TestAccess {
/ * public static void main (String [] args) {
T t = new T ();
t.j = 91;
t.k = 23;
t.kk = 54;
} * /
private int i = 9;
int j = 90;
protected int k = 92;
public int kk = 80;
}
package cn.test.testAccess1;
import cn.test.testAccess.TestAccess;
public class Test extends TestAccess {
public static void main (String [] args) {
TestAccess test = new TestAccess ();
test.kk = 60;
test.k = 20;
}
}
------ Solution ------------------------------------ --------
you obviously new is the parent class. .
public class Test extends TestAccess{
public static void main(String[] args){
TestAccess test = new TestAccess();
test.kk = 60;
test.k = 20;
}
this is the subclass. .
public class Test extends TestAccess{
public static void main(String[] args){
Test test = new Test();
test.kk = 60;
test.k = 20;
}
------ Solution ------------------------------------- -------
protected is a class , subclass, and the package can be seen , of course you can not visit
------ For reference only other bag ----- ----------------------------------
test.k error
------ For reference only ---------------------------------------
protected property such access is not to it !
The only public can now !
------ For reference only -------------------------------------- -
usually the fault of the program itself ;
------ For reference only -------------------------- -------------
------ For reference only ---------------------------------- -----
that references the parent class , I can not refer to the parent class member variables do
------ For reference only ---------------- -----------------------
have given you
没有评论:
发表评论