- Apr 02 Thu 2009 14:20
-
Static Member
- Apr 02 Thu 2009 14:19
-
認識DTD
- Apr 02 Thu 2009 14:17
-
Static & NonStatic
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++較不同的地方
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++較不同的地方
- Apr 02 Thu 2009 14:13
-
Friend(朋友類別)
- Apr 02 Thu 2009 14:11
-
Construction(建構子)
- Apr 02 Thu 2009 14:09
-
異常處理(Exception Handling)
- Apr 02 Thu 2009 14:08
-
強制轉型(Cast)
- Apr 02 Thu 2009 14:07
-
Conditional
- Apr 02 Thu 2009 14:07
-
空間效能(Sizeof)
- Apr 02 Thu 2009 14:05
-
時間效能(Time)



