singleton

Reply

Join Date: Feb 2007
Posts: 2
Reputation: mengani123 is an unknown quantity at this point 
Solved Threads: 0
mengani123 mengani123 is offline Offline
Newbie Poster

singleton

 
0
  #1
Feb 23rd, 2007
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
sanjay
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 1,824
Reputation: ithelp is a name known to all ithelp is a name known to all ithelp is a name known to all ithelp is a name known to all ithelp is a name known to all ithelp is a name known to all 
Solved Threads: 117
ithelp's Avatar
ithelp ithelp is offline Offline
Posting Virtuoso

Re: singleton

 
0
  #2
Feb 23rd, 2007
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.
Reply With Quote Quick reply to this message  
Join Date: Jan 2006
Posts: 34
Reputation: hemanthjava is an unknown quantity at this point 
Solved Threads: 0
hemanthjava hemanthjava is offline Offline
Light Poster

Re: singleton

 
0
  #3
Feb 23rd, 2007
Hi ithelp,
Your absolutely right. Also adding to it

Java Singleton pattern
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 4,189
Reputation: peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of 
Solved Threads: 483
Moderator
Featured Poster
peter_budo's Avatar
peter_budo peter_budo is offline Offline
Code tags enforcer

Re: singleton

 
0
  #4
Feb 23rd, 2007
Originally Posted by mengani123 View Post
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
Sanjay please 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...
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)

LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Java Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC