improve if else statement for multiple condition
- by kitokid
My superior said the following is bad code. But he didn't mention anything how to improve it.
What might be the alternative elegant way of coding below statements, without using if else?
if(name.equalsIgnoreCase("AAA")){
//do something
}else if(name.equalsIgnoreCase("BBB")){
//do something
}else if(name.equalsIgnoreCase("CCC")){
//do something
}else if(name.equalsIgnoreCase("DDD")){
//do something
}else if(name.equalsIgnoreCase("EEE")){
//do something
}else{
//do something
}
Edited: I am using Java 6.