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

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

為什么在輸入圖書(shū)名稱(chēng)之后不會(huì)運(yùn)行下面的輸出Book的語(yǔ)句呢

package com.BorrowBooks;


import java.util.Scanner;


public class book {
??public static void main(String[] args) {
???for(;;){
???System.out.println("歡迎使用借書(shū)系統(tǒng)");
???System.out.println("輸入命令:1.按名稱(chēng)查找圖書(shū)?? 2.按序號(hào)查找圖書(shū)");
???Scanner in=new Scanner(System.in);
???int choice = 3;
???int i = 0;
???int j = 0;
???String[] Book = {"高數(shù)","線代","概率論與數(shù)理統(tǒng)計(jì)","大學(xué)英語(yǔ)","數(shù)據(jù)庫(kù)","操作系統(tǒng)","java面向?qū)ο?};
???try{
????choice = in.nextInt();
???}catch(Exception e){
????System.out.println("命令輸入錯(cuò)誤,請(qǐng)根據(jù)提示輸入整形的數(shù)字");
????continue;
???}
???if(choice == 1){
????System.out.println("請(qǐng)輸入你要借的書(shū)的名稱(chēng)");
????try{
?????for(i=0;i<Book.length;i++){
??????if(Book[i]==in.nextLine()){
???????System.out.println("Book:"+Book[i]);
???????continue;?
?????}
????}catch(Exception e){
?????System.out.println("圖書(shū)不存在");
?????continue;
????}
???}else if(choice == 2){
????System.out.println("請(qǐng)輸入你要借的書(shū)的序號(hào)");
????try{
?????for(j=0;j<Book.length;j++){
??????if(j==in.nextInt()){
???????System.out.println("Book:"+Book[i]);
???????continue;
??????????????? }
????}catch(Exception e){
?????System.out.println("圖書(shū)不存在");
?????continue;
????}
???}else {
????System.out.println("你的選擇錯(cuò)誤");
???}
??}
??}
?}


正在回答

4 回答

Exception無(wú)法轉(zhuǎn)換為T(mén)hrowable

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

你這寫(xiě)的 問(wèn)題太多了

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

是我傻了哦,這樣寫(xiě)就好了

package com.BorrowBooks;


//import java.awt.print.Book;
import java.util.Scanner;


public class book {
??@SuppressWarnings("resource")
??public static void main(String[] args){
???for(;;){
???System.out.println("歡迎使用借書(shū)系統(tǒng)");
???System.out.println("輸入命令:1.按名稱(chēng)查找圖書(shū)?? 2.按序號(hào)查找圖書(shū)");
???Scanner in=new Scanner(System.in);
???int choice = 3;
//???int i= 0;
//???int j = 0;
//???String[] Book = {"高數(shù)","線代","概率論與數(shù)理統(tǒng)計(jì)","大學(xué)英語(yǔ)","數(shù)據(jù)庫(kù)","操作系統(tǒng)","java面向?qū)ο?};
???try{
????choice = in.nextInt();
???}catch(Exception e){
????System.out.println("命令輸入錯(cuò)誤,請(qǐng)根據(jù)提示輸入整形的數(shù)字");
????continue;
???}
???if(choice == 1){
//????System.out.println("請(qǐng)輸入你要借的書(shū)的名稱(chēng)");
//????for(i=0;i<Book.length;i++){
//????try{
//?????? ?in.nextLine().equals(Book[i]);
//???????System.out.println("Book:"+Book[i]);
//???????break;
//????}catch(Exception e){
//?????System.out.println("圖書(shū)不存在");
//?????continue;
//????}
//????}
//???System.out.println("Book:"+Book[i]);
????book Mc = new book();
????Mc.find1();
???}else if(choice == 2){
//????System.out.println("請(qǐng)輸入你要借的書(shū)的序號(hào)");
//????for(j=0;j<Book.length;j++){
//????try{
//?????? j=in.nextInt();
//?????System.out.println("Book:"+Book[j]);
//?????break;
//????}catch(Exception e){
//?????System.out.println("圖書(shū)不存在");
//?????continue;
//????}
//????}
//????System.out.println("Book:"+Book[j]);
????book Xh = new book();
????Xh.find2();
???}else {
????System.out.println("你的選擇錯(cuò)誤");
???}
??}
??}
??@SuppressWarnings("resource")
??public void find1(){
???int i = 0;
???String[] Book = {"高數(shù)","線代","概率論與數(shù)理統(tǒng)計(jì)","大學(xué)英語(yǔ)","數(shù)據(jù)庫(kù)","操作系統(tǒng)","java面向?qū)ο?};
???System.out.println("請(qǐng)輸入你要借的書(shū)的名稱(chēng)");
???Scanner in=new Scanner(System.in);
???String H = in.next();
???for(i=0;i<Book.length;i++){
???try{
????? ?H.equals(Book[i]);
??????System.out.println("Book:"+H);
??????break;
???}catch(Exception e){
????System.out.println("圖書(shū)不存在");
????continue;
???}
???}
??}
??@SuppressWarnings("resource")
??public void find2(){
???int j = 0;
???String[] Book = {"高數(shù)","線代","概率論與數(shù)理統(tǒng)計(jì)","大學(xué)英語(yǔ)","數(shù)據(jù)庫(kù)","操作系統(tǒng)","java面向?qū)ο?};
???System.out.println("請(qǐng)輸入你要借的書(shū)的序號(hào)");
???Scanner in=new Scanner(System.in);
???for(j=0;j<Book.length;j++){
???try{
????? j=in.nextInt();
????System.out.println("Book:"+Book[j]);
????break;
???}catch(Exception e){
????System.out.println("圖書(shū)不存在");
????continue;
???}
???}
??}
?}


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

根據(jù)你的代碼你必須輸入Book.length次才執(zhí)行輸出語(yǔ)句,而且你的判斷語(yǔ)句后面沒(méi)有執(zhí)行語(yǔ)句?if完然后干嘛?

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

JJJava

還有字符串判斷要用equals()
2016-08-01 回復(fù) 有任何疑惑可以回復(fù)我~
#2

JJJava

還有字符串判斷要用equals()
2016-08-01 回復(fù) 有任何疑惑可以回復(fù)我~
#3

Destiny命運(yùn) 提問(wèn)者

不要輸入Book.length次啊,我只是判斷我從鍵盤(pán)輸入的那個(gè)圖書(shū)的名稱(chēng)和我數(shù)組中的是否相同而已,
2016-08-02 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

為什么在輸入圖書(shū)名稱(chēng)之后不會(huì)運(yùn)行下面的輸出Book的語(yǔ)句呢

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

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

幫助反饋 APP下載

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

公眾號(hào)

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