petermarvey
16 years ago
Java類別2
petermarvey
16 years ago
constructor名稱同class, 無return, 不需void, 物件產生時即呼叫, initialization
petermarvey
16 years ago
constructor呼叫使用this(), 需再constructor第一行
petermarvey
16 years ago
private constructor須從public constructor呼叫, 無法建立object時呼叫
立即下載
petermarvey
16 years ago
overloading為方法名相同, parameters不同數量、型態
petermarvey
16 years ago
default constructor物件建立時呼叫, 若建立有parameters的方法, 則無預設建立, 需再建立non-parameters constructor (default constructor)