Answer Posted / manoj kumar
public class DateUtil implements Serializable,Cloneable {
private static volatile Dateutil instance;
private DateUtil() {
//no-op
}
public static DateUtil getInstance() {
if(instance==null) {
synchronized(DateUtil.this) {
if(instance==null) {
instance = new DateUtil();
}
}
return instance;
}
protected Object readResolve() {
return instance;
}
public Object clone() throws CloneNotSupportedException {
super.clone();
throw new CloneNotSupportedException;
}
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
Why put method is used?
Write a program to print 15 random numbers using foreach of java 8?
How do you classify Dialog Box?
Is linked list a linear or non-linear data structure?
How many unicode characters are there?
What are the six ways to use this keyword?
What is multithreading and its advantages?
What are heap memory and stack memory and what are memory tables.
Is empty set an element of empty set?
Is the empty set a singleton?
How do you check if a number is a perfect square?
What is the difference between method overriding and overloading?
If A Class Is Declared Without Any Access Modifiers, Where May The Class Be Accessed?
How to restrict a member of a class from inheriting by its sub classes?
what is thread? What are the high-level thread states? Or what are the states associated in the thread? : Java thread