Meaningless Drivel is fun!
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
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "private constructers" Watch "private constructers" New topic

private constructers

gopala krishna muvvala

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)
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

Joined: Oct 13, 2005
Posts: 46345
Welcome to JavaRanch
There was similar discussion last week: here.
I agree. Here's the link:
subject: private constructers
It's not a secret anymore!