Is it possible to do the following:
1. declare a static variable inside a method
2. have the method return the value of this variable
3. use this method in the main method of the same class to assign the result to a variable
I am getting an error when compiling. Error states that static is "illegal start of expression". If I remove the word static, it compiles and runs without error. I just don't completely understand static variables, and I'm having a hard time finding resources to explain it properly.
Thank you for your help!
Originally posted by Rakesh Sharma:
Member variable & Instance variables are the same thing. These are the variables which are declared in the class and used for the creation of object.
Local varables are the varables defined inside a method. These are used inside that particular method only and cannot be accessed outside that methods.
Hope this clarifies.