第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

有什么問題嗎大佬

異常頁(yè)

package?book;

public?class?NoBook?extends?Exception?{
????public?NoBook(){

????}
????public?NoBook(String?message){
????????super(message);
????}
}


主頁(yè)

package?book;

import?java.util.InputMismatchException;
import?java.util.Scanner;
public?class?BookTest?{
????public?static?void?main(String[]?args)?{
????????BookTest?test?=?new?BookTest();
????????test.trys();
????}
????public?void??trys(){
????????try?{
????????????showbooks();
????????}?catch?(InputMismatchException?e)?{
????????????System.out.println("請(qǐng)輸入數(shù)字");
????????????trys();
????????}catch?(NoBook?e){
????????????System.out.println(e);
????????????trys();
????????}
????}
????public?void?showbooks()??throws?NoBook{
????????Scanner?input?=?new?Scanner(System.in);
????????String[]?books?=?{"book1",?"book2",?"book3",?"book4"};
????????for(int?i=0;i<books.length;i++){
????????????System.out.print(i+1+":"+books[i]+"?");
????????}
????????System.out.println();
????????System.out.println("輸入命令:1按照名稱查找圖書?2按照序號(hào)查找圖書");
????????int?num?=?input.nextInt();
????????int?hasbook=0;
????????if?(num?==?1)?{
????????????System.out.println("請(qǐng)輸入圖書名");
????????????String?bookname=input.next();
????????????for(String?value:books){
????????????????if(value.equals(bookname)){
????????????????????hasbook=1;
????????????????}
????????????}
????????????if(hasbook==1){
????????????????System.out.println("書名:"?+?bookname);
????????????}else{
????????????????throw?new?NoBook("圖書不存在");
????????????}
????????}?else?if?(num?==?2)?{
????????????System.out.println("請(qǐng)輸入圖書序號(hào)");
????????????int?index?=?input.nextInt();
????????????if(index>books.length){
????????????????throw?new?NoBook("圖書不存在");
????????????}else{
????????????????System.out.println("書名:"?+?books[index-1]);
????????????}
????????}?else?{
????????????throw?new?NoBook("輸入錯(cuò)誤,請(qǐng)重新輸入");
????????}

????}
}


正在回答

2 回答

按你的代碼,當(dāng)提示輸入錯(cuò)誤之后,是不是就不能再輸入了?

每次執(zhí)行完throw?new?NoBook("輸入錯(cuò)誤,請(qǐng)重新輸入");之后程序就結(jié)束了,是不是得重跑程序才能繼續(xù)輸入正確的啊


0 回復(fù) 有任何疑惑可以回復(fù)我~

我看不出來(lái)


0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

有什么問題嗎大佬

我要回答 關(guān)注問題
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)