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 -

php - Boolean search on database with 5 million rows, very slow -

css - Text drops down with smaller window -