• Post Reply Bookmark Topic Watch Topic
  • New Topic

Singleton  RSS feed

 
norton stanley
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
String fullName = PATH + "." + name;
Class cl= Class.forName(fullName);
if(name.equalsIgnoreCase("MobileSearch")){
if(msearchType==null){
msearchType=(SearchInterface)cl.newInstance();
}
return msearchType;

}
if(name.equalsIgnoreCase("BookSearch")){
if(bsearchType==null){
bsearchType=(SearchInterface)cl.newInstance();
}
return bsearchType;

}
Am using reflection in the above code.I wanna get rid of the if statements to create objects.How do i do it.please help.
Thanks in advance.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!