这个问题在这里已经有了答案:关闭10年前。PossibleDuplicate:Whatisthebestwaytoreplaceorsubstituteif..elseif..elsetreesinprograms?如何避免多个if条件?例如:Publicvoidsearch(Stringa,b,c,d,e)StringaTerm;现在传递参数的单个和多个组合中的哪个包含“aTerm”?例如,输出可能如下:1-aTermappearsin"a"only2-aTermappearsin"a,c",and"e"3-aTermappearsin"d"and"e"对于每个单独的或可能的组合,我