my dog learned polymorphism
The moose likes Beginning Java and the fly likes need of static constructor Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Reply 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: 184
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: 184
sorry i got constructors are not static...
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 32611
    
    4
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: 32611
    
    4
It never occurred to me that could mean initialisers. Well caught, uj.
Muhammad Khojaye
Ranch Hand

Joined: Apr 12, 2009
Posts: 341
Also discuss here


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

Joined: Oct 13, 2005
Posts: 32611
    
    4
Thank you for noticing the old thread.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: need of static constructor
 
Similar Threads
what is it after all
Why would we change a non static method to a static method.
Single tone Vs Static
Child class calls method in Parent class.
key word static against constructor