[問題] this在建構子內的用法

看板java作者 (tsaiminghan)時間18年前 (2006/03/22 15:52), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/5 (看更多)
我看到課本上的程式碼 它寫到在建構子的寫this時(07),會呼叫(12)的建構子來用 我搞不清楚的是,程式怎麼知道要找哪一個來建構子來用? 01 public class time2(){ 02 private int hours; 03 private int minute; 04 private int second; 05 06 public Time2(){ 07 this (0,0,0) 08 } 09 public Time2(int h){ 10 this ( h, 0, 0); 11 } 12 public time2(int h, int m, int s){ 13 setTime(h, m, s); 14 } 15 16 public void setTime(int h, int m, int s){ 17 ......... 18 } 19 } -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.114.217.102
文章代碼(AID): #148G9BJp (java)
討論串 (同標題文章)
文章代碼(AID): #148G9BJp (java)