aspose file tools*
The moose likes Java in General and the fly likes re:constructors Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "re:constructors" Watch "re:constructors" New topic
Author

re:constructors

ashish sood
Greenhorn

Joined: Oct 03, 2009
Posts: 8
please help me with basic concepts of constructors like------>
can they be declared private???
can they be declared static???
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10451
    
    8

ashish sood wrote:
can they be declared private???
can they be declared static???


Did you try out writing a test class with constructors which fit these criteria? Did it compile? Did you get any errors?


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
ashish sood
Greenhorn

Joined: Oct 03, 2009
Posts: 8
yes i did...
the program compiled successfully with "private" but failed with "static" modifier
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Question answered :)

The next step is to think about situations where we might want private constructors, since it might seem counter-intuitive not to allow people to instantiate an instance of a class...
 
wood burning stoves
 
subject: re:constructors