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

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

Try...catch 循環(huán)未捕獲異常

Try...catch 循環(huán)未捕獲異常

茅侃侃 2021-12-10 17:03:38
當(dāng)程序運(yùn)行時(shí),當(dāng)輸入負(fù)數(shù)或字母時(shí),catch 不會(huì)捕獲錯(cuò)誤。否則程序運(yùn)行良好,其他任何事情都沒(méi)有錯(cuò)誤。當(dāng)輸入不正確的輸入時(shí),它只是捕獲未捕獲。 for (int customer=0; customer<numberOfCustomers; customer++) {                try {                    // get amount used by customer as String, convert to double                    GBused = Double.valueOf(Accounts[customer][USED]);                    // compute bill based on the customer's plan selection                    switch (Accounts[customer][SELECTION]) {                        case "Plan-A":                            bill = computeBill (GBused, PLAN[A][LIMIT], PLAN[A][PRICE]);                            break;                        case "Plan-B":                            bill = computeBill (GBused, PLAN[B][LIMIT], PLAN[B][PRICE]);                            break;                        case "Plan-C":                            bill = computeBill (GBused, PLAN[C][LIMIT], PLAN[C][PRICE]);                            break;                        case "Plan-D":                            bill = computeBill (GBused, PLAN[D][LIMIT], PLAN[D][PRICE]);                            break;                        default:                            bill = 0.00;                            break;                    }                    // convert the bill to a String and save into the array                    Accounts[customer][BILL] = String.valueOf(bill);                                } // end of try                               catch (NumberFormatException e) {                    System.out.println ("Values for GB used must be numeric");                               } 
查看完整描述

2 回答

?
慕的地10843

TA貢獻(xiàn)1785條經(jīng)驗(yàn) 獲得超8個(gè)贊

沒(méi)有異常被拋出。您需要檢查輸入處的有效值。對(duì)于字符,有類(lèi)型轉(zhuǎn)換并ASCII使用字符的值。


查看完整回答
反對(duì) 回復(fù) 2021-12-10
?
青春有我

TA貢獻(xiàn)1784條經(jīng)驗(yàn) 獲得超8個(gè)贊

嘗試使用“(Exception e)”來(lái)捕獲您可能遇到的任何可能的異常。


查看完整回答
反對(duì) 回復(fù) 2021-12-10
  • 2 回答
  • 0 關(guān)注
  • 146 瀏覽
慕課專(zhuān)欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號(hào)

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