Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

private constructers  RSS feed

 
gopala krishna muvvala
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 334
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes. Objects can be created in the class itself. Check Singleton pattern for more information
 
Campbell Ritchie
Sheriff
Posts: 53760
127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch
There was similar discussion last week: here.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!