我想知道如何在Java中執行方法,無論何時創建對象。每當創建對象時執行方法
例如:
public class Person {
private String name;
private int age;
private Date dateCreated;
public setName(String name){
...
}
... some other methods ...
public setDateCreated(){
this.dateCreated = new Date();
}
我真的想爲每個對象上要執行我的setDateCreated()方法創建時。
o真的,我認爲它是一樣的:S – aki 2012-04-12 20:15:15