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++較不同的地方
全站熱搜