随便举个例子
import java.sql.Date;
/**
*
* @author v
*/
public class User {
private String name;
private String address;
private Date birthday;
public String getName() {
return name;
}
public String getAddress() {
return address;
}
public Date getBirthday() {
if( birthday!=null )
return (Date)birthday.clone();
return null;
}
private User( String aName, String aAddress, Date aBirthday ){
name = aName;
address = aAddress;
birthday = aBirthday;
}
public static User createMe(){
return new User( "xiachi","nanning",Date.valueOf("1985-06-12") );
}
//Test this User class
public static void main(String args[]){
User me = User.createMe();
System.out.println( me.getName() );
System.out.println( me.getAddress() );
System.out.println( me.getBirthday() );
}
}