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
How do you make an arraylist empty in java?
What is the use of put method?
Define how does a try statement determine which catch clause should be used to handle an exception?
What about method local inner classes or local inner classes in java?
What is a instance variable in java?
How to disable caching on back button of the browser?
How is final different from finally and finalize?
What are inbuilt functions?
How can we create objects if we make the constructor private ?
What is the difference between heap memory and stack memory?
How does arraylist work in java?
What are the different types of multitasking?
Why are data types important?
What is the difference between the size and capacity of a vector?
Why is string buffer better than string ?