Forums Register Login

private constructers

+Pie Number of slices to send: Send
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 ]
+Pie Number of slices to send: Send
Yes. Objects can be created in the class itself. Check Singleton pattern for more information
+Pie Number of slices to send: Send
Welcome to JavaRanch
There was similar discussion last week: here.
I suggest huckleberry pie. But the only thing on the gluten free menu is this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 659 times.
Similar Threads
User defined First class objects
Constructor
main()
arrays & String
Can objects share each other's private data ?
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 19:35:34.