Answer Posted / hardeep thakur
Here is code to implement the singleton
public class SingletonClass {
private static SingletonClass singleObj ;
private SingletonClass(){}
public static synchronized SingletonClass getInstance()
{
if(singleObj ==null){
singleObj = new SingletonClass();
}
return singleObj;
}
public Object clone() throws CloneNotSupportedException
{
throw new CloneNotSupportedException();
}
}
| Is This Answer Correct ? | 7 Yes | 0 No |
Post New Answer View All Answers
How many types of constructors are used in java?
What is queue in java?
Is node a data type in java?
Why string is called as immutable?
Can a static class have a constructor java?
What do you mean by formatting?
What is volatile data type?
What is the static import?
What is the difference between math floor and math round?
Which variables are stored in stack?
What does replaceall do in java?
I am unable to find or learn about print command. I have a graphical program in core java in applet but i want to give print command but i have coding for that so if anyone know about this plz mail me on avdhesh_chauhan007@yahoo.co.in
What is executor memory?
What are the data types supported by java? What is autoboxing and unboxing?
What 4 doubled?