helloworld2.java

来自「清华大学辛运帏java程序设计第二版源代码」· Java 代码 · 共 23 行

JAVA
23
字号
public class HelloWorld2 {
	public static void main (String args[]) {
		int i = 0;
		String greetings [] = {
			"Hello world!",
			"No, I mena it!",
			"HELLO WORLD!!"
		};
		while (i < 4) {
			try {
				System.out.println (greetings[i]);
			} catch (ArrayIndexOutOfBoundsException e) {
				System.out.println("Re\|setting Index Value");
				i = -1;
			} catch (Exception e) {
				System.out.println(e.toString());
			} finally {
				System.out.println("This is always printed");
			}
			i++;
		} // while循环结束
	} // 主函数main结束
}

⌨️ 快捷键说明

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