Java Variable

02/06/2008

Java variables can be categorized into the following seven types:

  1. Class Variable
  2. Instance Variable
  3. Array Component Variable
  4. Method Parameter Variable
  5. Constructor Parameter Variable
  6. Exception Handler Parameter Variable
  7. Local Variable

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

is good and more information aout topic it is better i think

guru on December 19th, 2010 1:52 pm

THANX…….

CVU on February 17th, 2011 9:37 am

its very interesting

Ganesh on March 21st, 2011 11:11 am

Very Good Information For all Students Of Programing Language.

ThanK’S

SYED SAFDAR SHAH on April 28th, 2011 6:59 pm

[...] 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 [...]

Java Array&hellip on May 7th, 2011 7:12 am

I have my Java functions test tomorrow. Thanks for the help.

Java Learner on June 13th, 2011 2:40 pm

Vey good and easily understandable information

Thankz

Imthiaz on July 13th, 2011 7:22 am

Thanx alot it’s very helpful

Abhi on July 18th, 2011 9:40 am

[...] 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 [...]

Java Hashtable&hellip on August 17th, 2011 8:52 pm

Please provide the thread safety information for all the variables in multi threaded environment

RaMesh on September 8th, 2011 12:29 pm

please provide a java script for g-five n90

akash on October 6th, 2011 1:33 pm

I like it.
continue it.

Aziz on December 6th, 2011 7:08 pm

VERY GUD SIR

Anonymous on December 18th, 2011 11:34 am

thank you sir for giving my answer

ajai kumar gaur on December 25th, 2011 5:40 pm

is so good.. . . now i understand it very will keep it up. . more power to you

Anonymous on March 6th, 2012 5:29 pm

thanks its so good information.

Kakar on March 10th, 2012 11:15 am

Hi,
Can you please explain different scope of java variables?

Thanks for the website.Its lovely and very understanding!!

Rua

Rua on March 17th, 2012 4:55 pm

awesome………
very nice
.
.
.
.
.
myk

Anonymous on April 22nd, 2012 10:58 pm

thanks

prince on May 12th, 2012 4:55 am

thank you sir.here each and every topic is well explained.especially serialization nice……..

poojamanick on May 17th, 2012 2:15 pm


Email:

about
I am Joe, author of this blog. I run this with loads of passion. If you are into java, you may find lot of interesting things around ...more about me. Google+
java badge
Home