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
Hi Friends, i have searched in google but not clear. can you give bank example with synchronized keyword
What are the different types of features of the java collections framework? : java collections
How do I find jre path in windows?
In hyderabad, which s/w training center is best for java, other than corejava what r the new tools to learn in java,which tool is best & have current requirement,pls give me information about java to learn ?
What are the classes in the java collection framework? : java collections
What do you understand by synchronization? Why is it important?
What is java collection? : java collections
What is iterator in the java collections framework? : java collections
Which server-side script takes the input from JavaScript, can access the database if it needs to, and processes the data.
What are the different types of collections views being provided by the map interface? : java collections
What is the use of hashcode in java ?
What is an algorithm in java collection framework? : java collections
What are the types of the main implementing classes in the map interfaces? : java collections
What are the types of interface used in the java collections? : java collections
What are the interfaces in java collections? : java collections