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

Popular posts from this blog

php - cannot display multiple markers in google maps v3 from traceroute result -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -