During recent java interview question regarding if then else was asked and question was put up in the way that if you are given with 1000 if else conditions like
if(condition 1){
task 1
}else if (condition 2){
task 2
}else if (condition 3){
task 3
}
...
else if (condition 1000){
task 1000
}
i was asked to improvise the above code . I gave the answer that it could be improvised by using switch . But interviewer was not satisfied and asked for another approach. But i was unable to explain it. So i want to know if there is any better approach to do it.
Apologies for asking such a dumb question but i really want to know answer