靜態變量:是否爲每個類的對象分別創建類變量和它們。
實例變量:也是類變量,但是分別爲每個對象創建。
以上定義僅供參考。靜態聲明和非靜態聲明之間的區別
請解釋一下爲什麼我在這個類declaration.I得到錯誤知道那只是因爲我還沒有初始化的X。
class non_static{
public static void main(String args[])
{
int x;
System.out.println(x);
}
}
但是這個類聲明完全沒問題。這一計劃的
class static_example{
static int x;
public static void main(String args[])
{
System.out.println(x);
}
}
輸出爲0
請你解釋一下我爲什麼而局部變量不是靜態成員與默認值初始化。
哦,但實例變量是。 *另一方面,本地*變量不 - 看你的定義是哪裏.. – Voo 2012-07-12 18:26:58