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

📄 nestcatchexception.java

📁 java入门经典教程 java入门经典教程 java入门经典教程
💻 JAVA
字号:
 //例3.1.5 NestCatchException.java
class NestCatchException
{
	public static void prtInt(int a,int b,int c)
{
		System.out.println("a = "+a+" b = "+b);
		System.out.println("a/b = "+c);
	}
	public static void main(String args[])
	{
		int a = 5;
		int b = (int)(Math.random()*10);
		int c = 0;
		String arrayStr[]={"How ","are ","you\n"};
		try
		{
			System.out.println("Outer try...catch");
			c = a/b;
			prtInt(a,b,c);
			try
{
				System.out.println("Inner try...catch");
				b = (int)(Math.random()*10);
				c = a/b;
				prtInt(a,b,c);
				for(int i=0;i<4;i++)
				{
					System.out.print(arrayStr[i]);
				}
				System.out.println("Out of Inner try...catch");
			}catch(ArrayIndexOutOfBoundsException e){
				System.out.println(e);  
			}
			System.out.println("Out of Outer try...catch");
		}catch(ArithmeticException e){
			e.printStackTrace();
		}
		System.out.println("over");
    }
}

⌨️ 快捷键说明

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