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

楼主: PsMonkey (痞子军团团长)   2014-05-11 01:06:53
倒不如改成这样来体会 =="
※ 引述《pzyc79 (I'm bored)》之铭言:
: ===============Class Test:===============
: package a;
: public class Test {
: protected Test(){
: }
public Test(String nothing) {}
protected foo() {}
: }
: ===============Class Test2:==============
: package b;
: import a.Test;
: public class Test2 extends Test{
Test() {
super(); //OK
}
: void fun(){
: Test t = new Test(); //Test() is not visible
Test t = new Test(""); //OK
this.foo(); //OK
: }
: }
: WHY? 宣告protected不是可以在子类别中看见吗?
依照字面上解释,只能说你的疑惑我每天都有 [死]
作者: pzyc79   2014-05-11 01:14:00
只能说当protected写在建构子上意思跟写在成员上不一样吗还有你加上去的程式错了两个地方
楼主: PsMonkey (痞子军团团长)   2014-05-11 01:20:00
意思有到就好 [喂喂] 然后其他大致同上一篇推文
作者: singlovesong (~"~)   2014-05-11 01:41:00
其实版主真的蛮热心的阿...
作者: sbrhsieh (十年一梦)   2014-05-11 02:52:00
this.foo(); 改 t.foo(); 就不 OK,这就是.....人篸[误]

Links booklink

Contact Us: admin [ a t ] ucptt.com