Java Variables
Variables are data name that may be used to store a value. Variable may take different values at different times during execution.
Variables are may refer to some data types which are like int, float, char and etc.
Every variable in Java language has a specific type that determines the layout and size of the variable’s memory. The ranges of the values that can store with the memory and set of operations that can apply to the variable.

Syntax of variables
type variable_list;
Types of variables
- Local variable
- Instance Variable
- Static variable
Local variable
It defines within a block or method or constructor is called a local variable. These variables won’t work outside of the method or constructor.
void function(){
int a=10; // Local variable
}
Instance Variables
These variables are non-static variables and are declared in a class outside any type of method, constructor or block.
class A
{
static int b=10; //static variable
int c=5; //instance variable
void function1(){
int a=10; //local variable
}
Static Variable
Static Variable is declared with static keyword.
class A
{
static int b=10; //static variable
void function1(){
int a=10; //local variable
}
Quickly Find What You Are Looking For
OnlineTpoint is a website that is meant to offer basic knowledge, practice and learning materials. Though all the examples have been tested and verified, we cannot ensure the correctness or completeness of all the information on our website. All contents published on this website are subject to copyright and are owned by OnlineTpoint. By using this website, you agree that you have read and understood our Terms of Use, Cookie Policy and Privacy Policy.
point.com