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
2,230 posts since May 2006
Reputation Points: 769
Solved Threads: 128
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
15,436 posts since Dec 2004
Reputation Points: 2,806
Solved Threads: 902