I don't know when to use a static/non-static variable in a program.
package slides;
public class Person {
String name;
int age;
boolean isStaff;
public Person(String name, int age, boolean isStaff) {
// TODO Auto-generated constructor stub
this.name = name;
this.age = age;
this.isStaff = isStaff;
System.out.println(this);
}
/*
public static boolean Staf () {
return isStaff;
}
*/
}
I understand the difference between the non-static/static variable but I just don't know when to use each. So in the above code, why the function Staf
can not be static? (and when it should be static?)