Please tell me the difference between a global variable and an instance variable. I am a little bit confused about it. Also, what is a user-defined variable?
Asked
Active
Viewed 144 times
-4
-
1[FYI](http://java-latte.blogspot.in/2014/01/global-variable-vs-class-variable-vs.html) – Bhargav Modi Mar 13 '15 at 10:03
-
The closest thing to a 'global variable' in Java is implemented with a public constant in some (public) class or interface, as explained in http://stackoverflow.com/questions/4646577/global-variables-in-java. An instance variable is a field at the class level. – Oscar Mar 13 '15 at 10:04
1 Answers
0
Instance variables are non static variables declared in a class, but outside a method, constructor or any block.
Class(similar to global, as there is no term as global in java) variables also known as static variables are declared with the static keyword in a class, but outside a method, constructor or a block.

Community
- 1
- 1

codingenious
- 8,385
- 12
- 60
- 90