The Best way to predict your future is to create it - Every great individual common man
SCJP 1.4, SCWCD 1.5
Originally posted by raunak saxena:
hi Mr. sharma ,
I am posting one of the possible solution . And waiting for the solution that you want .
class Dog extends Exception {
public static final Dog INSTANCE = new Dog();
private Dog() { }
public static Dog getInstance(){
return new Dog();
}
public String toString() {
return "Woof";
}
}
class CopyDog {
public static void main(String[] args) {
Dog newDog = Dog.getInstance();
System.out.println(newDog == Dog.INSTANCE);//false
System.out.println(newDog);//Woof
}
}
Regards
The Best way to predict your future is to create it - Every great individual common man
Originally posted by Saurabh Vyas:
My answer would be as follows :
The Best way to predict your future is to create it - Every great individual common man
Originally posted by Ganesh Pujar:
May be through Anonymous Constructors, i tried it, but i think i'm in wrong path.![]()
SCJP 1.4, SCWCD 1.5
<a href="http://www.dantheman.pl" target="_blank" rel="nofollow">http://www.dantheman.pl</a>
<a href="http://www.dantheman.pl" target="_blank" rel="nofollow">http://www.dantheman.pl</a>
Originally posted by Saurabh Vyas:
Sharma Ji what is the actual answer !!!
I am egar to know that. I feel i am running out of ideas to make it work![]()
The Best way to predict your future is to create it - Every great individual common man
Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
OCA, Java SE 8
/** Code speaks louder than words */
Hareesh Ram Chanchali
SCJP 5.0, IBM Certified Solution Designer
Hareesh Ram Chanchali
SCJP 5.0, IBM Certified Solution Designer
Hareesh Ram Chanchali
SCJP 5.0, IBM Certified Solution Designer
"I'm not back." - Bill Harding, Twister
Hareesh Ram Chanchali
SCJP 5.0, IBM Certified Solution Designer
Consider Paul's rocket mass heater. |