Ex:
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
flyinsky76 發表在 痞客邦 留言(0) 人氣(19)
當要使用父類別的建構子,
必須在子類別中的建構子使用super
flyinsky76 發表在 痞客邦 留言(0) 人氣(12)
flyinsky76 發表在 痞客邦 留言(0) 人氣(28)
Ex:
long starttime,endtime;
flyinsky76 發表在 痞客邦 留言(0) 人氣(9)
flyinsky76 發表在 痞客邦 留言(0) 人氣(25)
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++較不同的地方
flyinsky76 發表在 痞客邦 留言(0) 人氣(56)