我腦海中有一個懷疑....有關的任何靜態的概念......類似方法,成員等
1)我們可以稱之爲&訪問任何非靜態方法,但任何靜態方法或變量靜態方法我們不能訪問任何非靜態方法或變量..... why。
2)但我們可以從靜態方法創建任何類的實例。
請告訴我理解我的問題更好的答案的理由。
class Class1
{
static int x=0;
int w = 0;
private static Class2 test()
{
w = 88; // give error because w is not a static member.
test1(); // give error because test1() is not a static function.
Class2 z = new Class2(); // here i am creating instance of class2
return z;
}
private int test1()
{
x = 9;
return x;
}
}
class Class2
{
}
感謝
這並不能真正幫助OP,因爲這正是他們正在尋求的。 – 2011-06-03 13:50:36