File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Static reference varaible. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Static reference varaible." Watch "Static reference varaible." New topic

Static reference varaible.

Narasimha Rao B.
Ranch Hand

Joined: Aug 26, 2002
Posts: 205
If we declare a varaible as static, it means it is a class variable as every one knows.
If we declare a reference variable as static, what it means?.....
Thanks in Advance,

Valentin Crettaz
Gold Digger

Joined: Aug 26, 2001
Posts: 7610
Could you explain how a variable is different from a reference variable?
Actually, there are two kinds of variables, reference variables that reference objects on the heap, and primitive variable that hold primitive values (1, 4.56f, false, ...).
When using the term "variable", we mean both reference and primitive variables. Both of them may be declared static, that is, they pertain to the class and not to an instance of that class.
An example of a static primitive variable could be a instance counter that increments each time an instance of the class is created.

An example of a static reference variable could be a singleton instance of a class.

[ March 26, 2003: Message edited by: Valentin Crettaz ]

[Blog] [Blogroll] [My Reviews] My Linked In
I agree. Here's the link:
subject: Static reference varaible.
jQuery in Action, 3rd edition