you can use setter for integer variable as your instance variable age
is integer:
public void setAge(String a)
{
try
{
this.age = Integer.parseInt(a);
}
catch(NumberFormatException e){
//.. code
}
}
0
solved Java Programming: Getter/Setter Questions