⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 throwsexception.java

📁 Java语言是目前最流行
💻 JAVA
字号:
//生声明异常
class ThrowException
{
	public static void main(String[] aa)
	{
		try
		{
			Method(0);
			Method(1);
		}
		catch(NumberFormatException e)
		{ System.out.println("\t捕获异常:"+e); }  
		catch(ArrayIndexOutOfBoundsException e)
		{ System.out.println("\t捕获异常:"+e); }
		finally
		{ System.out.println("\t finally块总是被执行."); }			
	}	

static void Method(int i) throws ArithmeticException,NumberFormatException
{
	System.out.println("\t调用方法method("+i+")");
	if (i==10)
	{
		System.out.println("\t没有异常");
		return;	
	}	
	else if(i==1)
	{
		String str = "abc";
		int k;
		k = Integer.parseInt(str);	
	}
}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -