package holinheritation2;
import java.util.Scanner;
public class Inheritation2 {
public static void main (String args[]) {
Animal wolf = new Animal();
Scanner scanner = new Scanner(System.in);
String name = scanner.next();
wolf.setName(name);
if (wolf.getName().equalsIgnoreCase("Kobe")) {
System.out.println("You are a wolf called Kobe!");
}
}
}
package holinheritation2;
import java.util.Scanner;
public class Animal {
private String name;
private int age;
public void setName(String name) {
this.name = name;
}
public String getName() {
return this.name;
}
`enter code here`}
What is the purpose of writing this.name = name
and is there any difference if I return "name" instead of "this.name" on the getName method? I think I understand this.name = name
however clarification is appreciated.