12th Oct 2019, 5:11 AM
Sanzid Sadman
Sanzid Sadman - avatar
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 ☺
12th Oct 2019, 5:15 AM
🇮🇳Omkar🕉
🇮🇳Omkar🕉 - avatar
+ 1
owh i see..thanks brother
12th Oct 2019, 5:17 AM
Sanzid Sadman
Sanzid Sadman - avatar