Java10个学员姓名存储在数组中,查找此班级是否有用户输入的学员姓名,有则"该学员在此班",否则"没有找到"
题目要求是键盘输入学生姓名,但是运行出来不管键入什么都显示没有找到,请问哪错了String[]name=newString[]{"一","二","三","四","五","...
题目要求是键盘输入学生姓名,但是运行出来不管键入什么都显示没有找到,请问哪错了
String []name=new String[]{"一","二","三","四","五","六","七","八","九","十"};//定义班级学员姓名数组
Scanner scanner = new Scanner(System.in);
System.out.print("请输入学生姓名:");
String student=scanner.next();
for(int i=0;i<name.length;i++){
if("name[i]".equals("student")){
System.out.println(name[i]);
break;
}
}System.out.println("没有找到"); 展开
String []name=new String[]{"一","二","三","四","五","六","七","八","九","十"};//定义班级学员姓名数组
Scanner scanner = new Scanner(System.in);
System.out.print("请输入学生姓名:");
String student=scanner.next();
for(int i=0;i<name.length;i++){
if("name[i]".equals("student")){
System.out.println(name[i]);
break;
}
}System.out.println("没有找到"); 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询