+ 1
why its giving me null?
2 Respostas
+ 6
Sanzid Sadman
Observe Line 3 to 7:
private String name;
public void setName(String n){
this.name=name;
}
What you have done here is you are reassigning name to itself .
Your local variable is n so use
this.name=n;
Not this.name=name;
another option
public void setName(String n)
change variable n with name like
public void setName(String name){
then this.name=name; will mean assigning local variable to instance variable.
Happy learning ☺
+ 1
owh i see..thanks brother