我想知道是否有任何方法可以优化此代码。
String[] array;
for(String s:array){
if(s.contains("one"))
//call first function
else if(s.contains("two"))
//call second function
...and so on
}
Run Code Online (Sandbox Code Playgroud)
字符串基本上是我从文件中读取的行。所以可以有很多行。我必须在这些行中查找特定的关键字并调用相应的函数。