What does the following error message mean: Can make a static reference to nonstatic variable?
Ans : The compiler is complaining that you are trying to reference the implicit instance variable this from within a class method. The Java language lets you define three kinds of variables: class variables, instance variables, and local variables (Q1.5). Class variables are defined on a per-class basis, and all instances of a class can access them. Instance variables are defined on a one-per-object basis, and you can access them only in connection with some specific instance of a class. Local variables are defined inside individual methods and can be accessed only from inside that same method. The “Can’t make a static reference …” error message most commonly arises in a class’s main(String[]) method, which the Java language requires to be a class method (declared with the static keyword; see Q1.6). The following code exemplifies the error: /* The compiler will complain about this: */ class StaticError { String myString = “hello”; public static void main(String[] args) { System.out.p