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

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

感覺(jué)有點(diǎn)奇怪,好像沒(méi)有正確使用異常。

package?com.jsdx;

import?java.util.Scanner;
import?java.util.Arrays;

public?class?RentBook?
{
	private?static?String[]?bookName?=?{"悟空傳","斗羅大陸","斗破蒼穹","擇天記","遮天"};
	
	public?RentBook()
	{
		
	}	
	
	public?static?void?main(String[]?args)
	{
		RentBook?rentBook?=?new?RentBook();
		rentBook.select();
	}
	
	public?void?bookNumber()
	{
		System.out.println("輸入圖書(shū)序號(hào):");
		@SuppressWarnings("resource")
		Scanner	inNumber?=?new?Scanner(System.in);
		if(inNumber.hasNextInt())
		{
			int?number?=?inNumber.nextInt();
			if(number?>?0?&&?number?<=?bookName.length)
			{
				System.out.println("圖書(shū)信息:"?+?bookName[number-1]);
			}
			else
			{
				try?
				{
					System.out.println("沒(méi)有該序號(hào)圖書(shū)!");
					select();
				}?catch?(Exception?e)?
				{
					e.printStackTrace();
				}
			}
		}
		else
		{
			try?
			{
				System.out.println("輸入錯(cuò)誤,請(qǐng)輸入數(shù)字!");
				bookNumber();
			}?catch?(Exception?e)?
			{
				e.printStackTrace();
			}
		}
	}
	
	public?void?inName()
	{
		System.out.println("輸入圖書(shū)名稱:");
		@SuppressWarnings("resource")
		String?name?=??new?Scanner(System.in).nextLine();
		boolean?flag?=?Arrays.asList(bookName).contains(name);	
			if(flag)
			{
				System.out.println("圖書(shū)信息:"?+?name);
			}
			else
				try?
				{
					System.out.println("沒(méi)有該名稱圖書(shū)!");
					select();
				}?catch?(Exception?e1)?
				{
					e1.printStackTrace();
				}
	}
	
	public?void?select()
	{
		System.out.println("輸入命令:1-按書(shū)名查找圖書(shū);?2-按序號(hào)查找圖書(shū)");			
		@SuppressWarnings("resource")
		Scanner?inCammond?=?new?Scanner(System.in);
		try
		{
			if(inCammond.hasNextInt())?
			{
				int?cammond?=?inCammond.nextInt();
				if(cammond?==?1)
				{
					inName();
				}
				else?if?(cammond?==?2)
				{
					bookNumber();
				}
				else
				{
					throw?new?CammondException();
				}
			}
			else
			{
				throw?new?CammondException();
			}
		}catch?(CammondException?e)?
		{
			System.out.println("命令無(wú)效,請(qǐng)按提示輸入命令?。。?);
			select();
		}
	}
}

//CammondException時(shí)一般的自定義類型

正在回答

1 回答

我其實(shí)都不懂什么是異常

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

舉報(bào)

0/150
提交
取消
Java入門(mén)第三季
  • 參與學(xué)習(xí)       409767    人
  • 解答問(wèn)題       4510    個(gè)

Java中你必須懂得常用技能,不容錯(cuò)過(guò)的精彩,快來(lái)加入吧

進(jìn)入課程

感覺(jué)有點(diǎn)奇怪,好像沒(méi)有正確使用異常。

我要回答 關(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)