I am going to start with a basic description for java variables because variables in any language are very useful works as a building block for any program , so lets start...
First of all What is meaning of word variable it means not having a fixed pattern. Its a container hold a value for u , When we define a variable with value at beginning of any program after some code we can change value of that variable , of course there are lots of other benefits of variables in java ....so we will describe later.
A variable is also called field so do not confuse . In java we can define variables as :
1. Instance variables
2. Class variables
3. Local variables
1. Instance variables : A variables which also called non static field define with out static keyword and value of instance variable are unique for each instance of a class.
Note : you can not use instance variable in static method till you can not create a object of that class having instance variable.
2. Class variables : A variable with static modifier and value of a static field is same in all over code and we use it by class name do not need to create object.
3. Local variables : A variable only visible to the method where they are declared , no any use of special keyword with local variables.
How we can use these variables:
first we have to define datatype then name of variable end with semicolon like:
int varA ;
now you can assign value to variable here e.g: int varA = 10; or you can assign value where ever you want in code. The advantage of java variable are that we can define and declare a variable any where in the code unlike C.