How to implement or use the singleton class in java?
Answer Posted / amit sharma
singleton is a design pattern. in this per application only
one object should exist.we implement it as follows:
public class abcd
{
private static abcd instance=null;
protected abcd()
{
//only to defeat instantiation;
}
public static abcd getInstance()
{
if(instance==null)
{
instance=new abcd();
}
return instance;
}
| Is This Answer Correct ? | 11 Yes | 4 No |
Post New Answer View All Answers
What are the types of interface used in the java collections? : java collections
What are the main classes of the list interfaces? : java collections
What are the types of the main implementing classes in the map interfaces? : java collections
What is the use of the list interface in the java collection? : java collections
Hi we have an urgent requirement for Java/J2ee technical lead position & also looking for "Java Guidewire claimcentre" experienced professional for Bangalore location if interested can reach srisanh@gmail.com
my interviewer asked me what technical specification you used how to answer that question
How do I find jre path in windows?
what is mean by hasing and maping in java platform and advantage?
Which interface does java.util.hashtable implement?
What are the classes in the java collection framework? : java collections
Which java collection class can be used to maintain the entries in the order in which they were last accessed?
What are the different types of features of the java collections framework? : java collections
What are the different types of classes implemented in the set interfaces? : java collections
What is the Spring2.5 MVC Navigation flow?
can u draw class/object diagram for ATM