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

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

InputMismatchException cannot be resolved to a type

try{
			System.out.println("輸入第一個(gè)數(shù)");
			Scanner?input?=?new?Scanner(System.in);
			int?firstNum?=?input.nextInt();
			System.out.println("輸入第二個(gè)數(shù)");
			int?secondNum?=?input.nextInt();
			int?result?=?firstNum/secondNum;
			System.out.println("兩數(shù)之商為"?+?result);
		}?catch?(ArithmeticException?e)?{
			System.out.println("除數(shù)為0");
		}?catch?(InputMismatchException?e){
			System.out.println("需要輸入整數(shù)");
		}?catch?(Exception?e){
			System.out.println("不知名錯(cuò)誤");
		}

剛開(kāi)始提示“InputMismatchException cannot be resolved to a type”,后來(lái)在前面import 了 java.util.InputMismatchException之后就OK了,但是AritheticException 這個(gè)異常就不需要import什么類(lèi)啊,不明白是怎么回事~~求指導(dǎo)?


? java.lang.RuntimeException
? ? ? ? ? ? ?java.util.NoSuchElementException
? ? ? ? ? ? ? ? ?java.util.InputMismatchException

java.lang.RuntimeException

? ? ? ? ? ? ?java.lang.ArithmeticException

正在回答

2 回答

在前面加入import java.util.*;就可以了

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

因?yàn)锳rithmeticException這個(gè)類(lèi)是存在于java.lang這個(gè)包的,默認(rèn)情況下這個(gè)包中的所有類(lèi)會(huì)被自動(dòng)導(dǎo)入所有的程序。而InputMismatchException是java.util的包,需要手動(dòng)導(dǎo)入

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

舉報(bào)

0/150
提交
取消

InputMismatchException cannot be resolved to a type

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

購(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)