public class Demo6{
public static void main(String[] args){
String[] names = {"张一","李二","王三","赵四","郭六","冯七"};
java.util.Scanner sc = new java.util.Scanner(System.in);
System.out.print("请输入您要查找的用户姓名:");
String inputName = sc.nextLine();
int index = 0;
String result = "查无此人";
while(index<names.length){
if(names[index].equals(inputName)){
result = "找到啦";
break;
}
index++;
}
System.out.println(result);
}
}
public static void main(String[] args){
String[] names = {"张一","李二","王三","赵四","郭六","冯七"};
java.util.Scanner sc = new java.util.Scanner(System.in);
System.out.print("请输入您要查找的用户姓名:");
String inputName = sc.nextLine();
int index = 0;
String result = "查无此人";
while(index<names.length){
if(names[index].equals(inputName)){
result = "找到啦";
break;
}
index++;
}
System.out.println(result);
}
}