for(int i=0;i<people.length;i ){
if(people[i].equals("Don")){
return "Don";
}
if(people[i].equals("John")){
return "John";
}
if(people[i].equals("Kent")){
return "Kent";
}
}
return "";
}
Refactor:
String foundPerson(String[] people){
List candidates=Arrays.asList(new String[]{"Don","John","Kent"});
for(int i=0;i<people.length;i )
if(candidates.contains(people[i]))
return people[i];
return "";
}
上一篇: 在jboss,webshpere,weblogic下扩展发布新的MBean!
下一篇: hibernate配置笔记
文章整理:西部数码--专业提供域名注册、虚拟主机服务
http://www.west263.com
以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!




