本帖最后由 徐梦侠 于 2012-10-19 19:00 编辑
可以用Map集合,感觉更方便些。
import java.util.HashMap;
public class Test {
public static void main(String[] args) {
String[] English_names={"zhangsan","lisi","wangmazi"};
String[] Chinese_names={"张三","李四","王麻子"};
String work="lisi";
judgeName(English_names, Chinese_names, work);
}
private static void judgeName(String[] English_names,
String[] Chinese_names, String work) {
HashMap<String,String> workerName=new HashMap<String, String>();
for(int i=0;i<English_names.length;i++){
workerName.put(English_names, Chinese_names);
}
if(workerName.get(work)==null){
System.out.println("不存在此人");
}else{
System.out.println(work+" 的中文名是:"+workerName.get(work));
}
}
} |