Java variables can be categorized into the following seven types:
1) Class Variable
A java class variable is a field declared using the keyword static within a java class, or with or without the keyword static within a java interface declaration.
2) Instance Variable
Java variables that are declared without static keyword are instance variables.
3) Array Component
Array components are unnamed java variables that are created and initialized to default values whenever a new java array object is created.
4) Method Parameter
Java variables declared in the method declaration signature are method parameter variables. Whenever a java method is invoked a variable is created in the same name as it is declared.
5) Constructor Parameter
This is similar to the java method parameter variable. The same way, for all the java variables declared in the constructor a variable is created whenever it is invoked.
6) Exception Handler Parameter
Java variables that are declared in the catch clause of a java exception handling mechanism. Whenever a java exception is caught, exception handler parameter variable is created.
7) Local Variable
Java variables that are declared in a block inside a java method or for loop is called a java local variable.
Reference: Java Language Specification 4.12.3
Comments are closed for "Java Variable".
is good and more information aout topic it is better i think
THANX…….
its very interesting
Very Good Information For all Students Of Programing Language.
ThanK’S
[…] example, imagine if you had to store the list of countries in individual java variables and manipulate them. You will have more than hundred variables to manage. Can’t imagine, it […]
I have my Java functions test tomorrow. Thanks for the help.
Vey good and easily understandable information
Thankz
Thanx alot it’s very helpful
[…] in java. You can store and retrieve a ‘value’ using a ‘key’ and it is an identifier of the value stored. It is obvious that the ‘key’ should be […]
Please provide the thread safety information for all the variables in multi threaded environment
please provide a java script for g-five n90
I like it.
continue it.
thank you sir for giving my answer
is so good.. . . now i understand it very will keep it up. . more power to you
Hi,
Can you please explain different scope of java variables?
Thanks for the website.Its lovely and very understanding!!
Rua
awesome………
very nice
.
.
.
.
.
myk
thanks
thank you sir.here each and every topic is well explained.especially serialization nice……..
good and interesting topics…
Mr. joe i appriciate ur valuable thoughts on variable type and i told in interview all this types but he got angry on me said there are only two type variable in java static and non static.
so will u pls elobrate with example……..m waiting
hi, useful info but ur missing reference variables
nice …i like your tutorial
[…] a primitive type, determining the equality is simple. We all know an int value of 10 is always equal to 10. But this […]
Hi Joy,
Can you make is clear….
what is difference betwleen java method parameter variable and local variable ?
for eg.
public class A{
public static int k; // this is class variable
public int j; // this is instance variable
public void show (int m, String name){
int j = 34;
String title = ” Java book”;
//… something
}
}
now my question is what difference between variable m and variable j ? since scope of both variable with in a method.
sorry ! your name is “Joe” not “Joy”.
its by mistake, hope you won’t mind
good one but,i want how to declare a variable in java.
difference declaring a variable in c and java can explain it.
Nice I liked it very much !!
[…] To specifically denote that the instance variable is used instead of static or local variable.That […]