File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes need of static constructor Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "need of static constructor" Watch "need of static constructor" New topic
Author

need of static constructor

shukla raghav
Ranch Hand

Joined: Aug 03, 2008
Posts: 200
why would we ever need a static constructor. what does it mean by a static constructor ?

static refers to "not associated with specific object" and can be called using class reference rather than object reference. But how does this apply to a constructor
shukla raghav
Ranch Hand

Joined: Aug 03, 2008
Posts: 200
sorry i got constructors are not static...
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38068
    
  22
Never heard of a "static constructor". A constructor has an access modifier (public/private/protected/---) the name of the class and (parameters). You never write static.
Embla Tingeling
Ranch Hand

Joined: Oct 22, 2009
Posts: 237
shukla raghav wrote:why would we ever need a static constructor. what does it mean by a static constructor ?

static refers to "not associated with specific object" and can be called using class reference rather than object reference. But how does this apply to a constructor


The closest you come to a static constructor is a static initializer. It works like a static default constructor would work if it existed.

Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38068
    
  22
It never occurred to me that could mean initialisers. Well caught, uj.
Muhammad Khojaye
Ranch Hand

Joined: Apr 12, 2009
Posts: 449

Also discuss here


http://muhammadkhojaye.blogspot.com/
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38068
    
  22
Thank you for noticing the old thread.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: need of static constructor
 
Similar Threads
Child class calls method in Parent class.
Single tone Vs Static
key word static against constructor
what is it after all
Why would we change a non static method to a static method.