aspose file tools*
The moose likes Java in General and the fly likes Static reference for object Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Static reference for object" Watch "Static reference for object" New topic
Author

Static reference for object

Vijay maske
Greenhorn

Joined: Oct 29, 2010
Posts: 2
Can I have object reference as static?

Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

Yes you can.

Please UseCodeTags when posting code. It will highlight your code and make it much easier to read. It probably will also increase the number of people helping you. I'll add them for you since you are new so that you can see the difference.


"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

And welcome to the JavaRanch.
Bharath Raja
Ranch Hand

Joined: Jan 21, 2009
Posts: 111
Wouter Oet wrote:
Yes you can.


I'm agree with you... But the main behavior of static modifier is available before we instantiate the class, right... then what is the purpose of having reference variable as static...


Life is either daring something or nothing - Helen Keller
Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 3379
    
    9
The singleton pattern is a common example:
 
wood burning stoves
 
subject: Static reference for object
 
Similar Threads
what exactly is -Toplevel class
Why can't I inherit an interface of a Class in Java
Single tone Vs Static
Calling already instantiated objects
Passing variables