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

📄 try_catch_finally.java

📁 主要介绍了JAVA的基本知识和异常处理的知识
💻 JAVA
字号:
public class try_catch_finally{
public static void main (String args[]) {
	  int i = 0;
	  String greetings [] = {
	    "1 Hello world!",
	    "2 No, I mean it!",
	    "3 HELLO WORLD!!"
	  };
	  while (i < 4) {
	    try { 
	    System.out.println (greetings[i]);
	    } catch (ArrayIndexOutOfBoundsException e){
                System.out.println( "数组下标越界");
	           
	    } finally {
	    System.out.println("This is always printed");
	    }
	    i++;
	    } // end while()
	    } // end main() 
}

  /*  当循环被执行时,下述在屏幕上出现的信息将改变。
	1 Hello world!
	This is always printed
	2 No, I mean it!
	This is always printed
	3 HELLO WORLD!! 
	This is always printed
	数组下标越界 
	This is always printed */
 

⌨️ 快捷键说明

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