怎么回事呢?
package borrowBook;
import java.util.Scanner;
public class BorrowBook {
public static void main(String[] args) {
String[] bookList =new String[4];
bookList[0]="高数";
bookList[1]="数据结构";
bookList[2]="大学英语";
bookList[3]="军事理论";
System.out.println("输入命令:1-按照名称查找图书;2-按照序号查找图书");
int order=0;
Scanner scanner=new Scanner(System.in);
try{
order=scanner.nextInt();
}catch (Exception e){
System.out.println("命令输入错误!请根据提示输入数字命令");
}
switch (order){
case 1:
System.out.println("输入图书名称:");
String bookName;
bookName=scanner.next();
try {
for (int i=0;i<= bookList.length;i++);
String book=bookList.get(i);
if(bookName.equals(book)){
System.out.println("book:"+book);
break;
}
}catch (Exception e){
System.out.println("图书不存在!");
}
break;
case 2:
System.out.println("输入图书序号:");
int num=0;
try {
num=scanner.nextInt();
}catch (Exception e){
System.out.println("命令输入错误!请根据提示输入数字命令");
break;
}
try {
System.out.println("book:"+bookList.get(num-1));
}catch (Exception e){
System.out.println("图书不存在!");
}
break;
default:
System.out.println("抱歉,没有此项命令!");
}
}
}