[问题] 在子类别new建构子为protected的父类别

楼主: pzyc79   2014-05-11 00:53:48
===============Class Test:===============
package a;
public class Test {
protected Test(){
}
}
===============Class Test2:==============
package b;
import a.Test;
public class Test2 extends Test{
void fun(){
Test t = new Test(); //Test() is not visible
}
}
WHY? 宣告protected不是可以在子类别中看见吗?
作者: luoqr (.....)   2014-05-11 01:00:00
是在 new Test2() 时 super() 看的见, 不是在new Test()看见default 是在同一个pkg下看的见没错呀 XD
楼主: pzyc79   2014-05-11 03:43:00
在等这句...代换一下protected是在子类别下看的见没错呀 XD
作者: luoqr (.....)   2014-05-11 12:34:00
这应该是定义问题 constructor 和 function 不一样

Links booklink

Contact Us: admin [ a t ] ucptt.com