close

Static - 沒有隱含的this參考指標指向物件,只允許存取static成員

NonStatic - 可直接存取non-static & static 成員

Example:

public class Test
{
void aMethod()
{
bMethod(); //可直接呼叫
dMethod(); //可直接呼叫
}
void bMethod() {};
static void cMethod()
{
bMethod(); //不可直接呼叫
dMethod(); //可直接呼叫
}
static void dMethod()
{
new Test().bMethod(); //可呼叫
}
}

結論: java中在類別裡Method可以由前呼叫到後面一個是跟C++較不同的地方

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 flyinsky76 的頭像
    flyinsky76

    Deja Vu

    flyinsky76 發表在 痞客邦 留言(0) 人氣()