954,510 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

singleton

write a sample code to create singleton class using java. ensure that only one instance will be creted and same will be returned always.


please do it.

sanjay

mengani123
Newbie Poster
2 posts since Feb 2007
Reputation Points: 10
Solved Threads: 0
 

Make its constructor private and have a static method called instance(), inside this method create a instance only once , and return the same instance everytime this static method is called.

ithelp
Nearly a Posting Maven
Banned
2,230 posts since May 2006
Reputation Points: 769
Solved Threads: 128
 

Hi ithelp,
Your absolutely right. Also adding to it

Java Singleton pattern

hemanthjava
Light Poster
34 posts since Jan 2006
Reputation Points: 10
Solved Threads: 0
 
write a sample code to create singleton class using java. ensure that only one instance will be creted and same will be returned always. please do it. sanjay


Sanjayplease do it on your own and return back when you get problem with code, not problem with personal lazines of actualy learning something.

Important thing is to read forums rules befor signing up for the forum. This forum doesn't provide solution to courseworks/assignments/project works. We help individuals which want to learn. Copy & paste somebody's work and put your signature bellow it is not our way of helping. If you want somebody else to do your work find other forum, but you will be charged for it...

peter_budo
Code tags enforcer
Moderator
15,436 posts since Dec 2004
Reputation Points: 2,806
Solved Threads: 902
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You