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 Beginning Java and the fly likes private constructers 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 "private constructers" Watch "private constructers" New topic
Author

private constructers

gopala krishna muvvala
Greenhorn

Joined: Aug 26, 2008
Posts: 3
Is possible to create object for private constructer in java

in this way

class demo
{
private demo(String s)
{
System.out.println(s);
}
public static void main(String[] ar)
{
demo d=new demo("gopal");
}
}
[ August 26, 2008: Message edited by: gopala krishna muvvala ]
satishkumar janakiraman
Ranch Hand

Joined: May 03, 2004
Posts: 334
Yes. Objects can be created in the class itself. Check Singleton pattern for more information
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38087
    
  22
Welcome to JavaRanch
There was similar discussion last week: here.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: private constructers
 
Similar Threads
main()
arrays & String
User defined First class objects
Constructor
Can objects share each other's private data ?