作者stellvia7 (stellvia)
看板java
標題[問題] class global 參數宣告處使用new class的問題
時間Tue Jan 4 15:40:51 2011
我不知道怎麼說比較清楚 程式碼如下
class test02
{
test02()
{
System.out.print("test02\n");
}
}
public class test01
{
test01()
{
System.out.print("test01\n");
}
test02 t02 = new test02();
public static void main(String[] argv) {
test01 t01 = new test01();
}
}
我在class test01 中 ,寫了這一行test02 t02 = new test02();
(1)那麼test01 class 跟 test02 class 的關係是啥?
(2)在main中應該是不能使用 t02物件的對吧
(3)再來t01 跟 t02 應該是屬於不同process吧!
感恩 謝謝!!
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 220.130.36.2
→ calais007:回答(3):是同一個 01/04 19:11
→ calais007:回答(2)不可以,但你宣告成static就可以 01/04 19:13
→ calais007:(1):看不懂你要問啥關系,如果是OO的觀念就是都沒關係 01/04 19:17