+ 2
What is the difference between class variable,local variable,static variable,global variable,instance variable?
2 Answers
+ 10
"Class Variable"
In object-oriented programming with classes, a class variable is a variable defined in a class of which a single copy exists, regardless of how many instances of the class exist. A class variable is not an instance variable. It is a special type of class attribute (orclass property, field, or data member).
"Local Variable"
A local variable in Java is a variable that's declared within the body of a method. Then you can use the variable only within that method.
"Static Variable"
Static variable. syntax: static int age; Note: Static variable's value is same for all the object(or instances) of the class or in other words you can say that all instances(objects) of the same class share a single copy of static variables.
"Global Variable"
Java does not have any concept ofglobal variables. There is either an instance variable or a class variable. A class variable is also known as static field/variable ,and is shared by all the objects/instances of the class.
"Instance Variable"
In object-oriented programming with classes, an instance variable is a variable defined in a class (i.e. a member variable), for which each instantiated object of the class has a separate copy, or instance. An instance variable is similar to a class variable.
"Hope this helps...đ"
+ 1
thank you so much that helped me a lotđđ