I have a code in here.
I want to ask why we write
instead of
?
public class PersonalDetails {
private String name;
private int age;
private String gender;
private String qualification;
public PersonalDetails(String name, int age, String gender, String qualification) {
this.name = name;
this.age = age;
this.gender = gender;
this.qualification = qualification;
}
public int getAge() {
return age;
}
public String isGender() {
return gender;
}
public String getName() {
return name;
}
public String getQualification() {
return qualification;
}
public static void main(String[] args) {
PersonalDetails person = new PersonalDetails("The Anh", 20, "Male", "Studying");
System.out.println("Name: " + person.getName()
+ "\nAge: " + person.getAge()
+ "\nGender: " + person.isGender()
+ "\nQualification: " + person.getQualification());
}
}
I want to ask why we write
public String getName() {
return name;
}
instead of
public String getName() {
return this.name;
}
?