Possible Duplicate:
What is the best way to replace or substitute if..else if..else trees in programs?
How can I avoid multiple if conditions? For example:
Public void search(String a,b,c,d,e)
String aTerm;
Now which of the single and multiple combinations of passed arguments contain "aTerm"? For example the output could be following:
1 - aTerm appears in "a" only
2 - aTerm appears in "a,c", and "e"
3 - aTerm appears in "d" and "e"
For each single or possible combination I want to call a specific function. I wrote so many if conditions but it looks bad. For example:
If(aTerm. equalsIgnoreCase(a)){ call function a();}
If(aTerm. equalsIgnoreCase(b)){ call function b();}
If(aTerm. equalsIgnoreCase(b) and aTerm. equalsIgnoreCase(b)){ call function ab();}
…………………… and so on………………………….
Is there any cleaner way to do it? Solution could be in PHP or Java.