看板 java 關於我們 聯絡資訊
※ 引述《stellvia7 (stellvia)》之銘言: : 我不知道怎麼說比較清楚 程式碼如下 : 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 的關係是啥? aggregation : (2)在main中應該是不能使用 t02物件的對吧 何謂 t02 物件? 你程式跑的時候, 生成了一個 test01 的 obj (t01) 這個 obj 裡面又指向一個 test02 的 obj 如果你是要用 t01 這 instance 裡的 t02 就 t01.t02 就行了 : (3)再來t01 跟 t02 應該是屬於不同process吧! 你知道什麼是 process 嗎? : 感恩 謝謝!! -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 61.238.156.185