java - Getter for mutable object -
i read many articles how write right getter/ setter mutable object date or array. when changed on
public date getdateto() { return (date) dateto.clone(); } public void setdateto(date dateto) { this.dateto = (date) dateto.clone(); }
i java.lang.nullpointerexception
. means shoul initialize date in (post)constructor?
it dateto
not constructed, there nothing clone. answer yes - should initialize it.
Comments
Post a Comment