How to create an instance of a class if the class has
private constructor?
Answer Posted / eswar
u can create instance like this...
class Ex
{
public static Ex e=null;
private Ex()
{}
public Ex getObj()
{
if(e==null)
e=new Ex();
return e;
}
}
Actually the above coding is example for singleton Java
class.... which creates omly one object per JVM
| Is This Answer Correct ? | 6 Yes | 1 No |
Post New Answer View All Answers
Why does it take so much time to access an applet having swing components the first time?
what is the difference between process and thread? : Java thread
What an i/o filter?
What is 32 bit float?
What is the main functionality of the remote reference layer?
What is a treemap in java?
What is port number in java?
Is finalize() similar to a destructor?
In java, what is the difference between method overloading and method overriding?
What will be the output of round(3.7) and ceil(3.7)?
What is method in java ?
What is a return in java?
Explain the use of sublass in a java program?
Tell us something about set interface.
FOR EXAMPLE WE R HAVING TWO LIST ELEMENTS ..BOTH LISTS CONTAINS ID,NAME,PLACE ..I NEED TO COMPARE BOTH IDS IN TWO LISTS,IF ID'S R SAME MEANS WE HAVE ADD THE DETAILS(LIKE NAME,PLACE) TO MAP...HOW IS POSSIBLE ?CAN ANY ONE SUGGEST?