This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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 Android Security Essentials Live Lessons this week in the Android 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: 10171
    
    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...
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: re:constructors
 
Similar Threads
JPQL Functions
Aaargh!
iPhone simulators
Regex expressions
Isolating one line