An instance variable is a variable that is declared inside a class and is accessible from any method within that class. An example of an instance variable would be:
class Person {
private String name;
public Person(String name) {
this.name = name;
}
public String getName() {
return name;
}
}
A property is a special type of variable that is used to access a class’s member variables from outside the class. An example of a property would be:
class Person {
private String name;
public Person(String name) {
this.name = name;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}