Font Awesome Icons


Variables in Java

In Java, objects store their states in variables. Variables are used as containers to hold values (int,float,double, long, String etc…) during the life cycle of an application.

Types of Variables in Java

Instance Variable

Variables which are defined without the static keyword and are outside any method  are known as Instance Variables. These variables are called instance variables because their values are instance specific and values of these variables are not shared among instances

Static variable

Variables which are declared with a static keyword inside a Class (outside any Method) are known as Class variable or Static variable. They are known as Class level variables because values of these variables are not specific to any instance but are common to all instances of a class. Such variables are shared by all the instances of an Object.


Local Variables

When a variable is declared inside a Method it is known as  Local Variable or method local variable. The scope of local variables is only inside the Method, which means local variables cannot be accessed outside that Method.


Hi, Welcome to etechvidya