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
What does \ mean in regex?
What is r in java?
What is autoboxing and unboxing?
Explain the difference between private, public, package and protected in java?
How big is a gigabyte?
What restrictions are placed on method overloading in java programming?
How to provide security in java
Why singleton class is used in java?
What is return code?
what is thread? What are the high-level thread states? Or what are the states associated in the thread? : Java thread
Is a copy constructor?
What lambda means?
Is 9 a prime number?
What is difference between arraylist and list in java?
How many bytes is a unicode character?