helloworld2.java

来自「java程序设计 清华出版社 孙燮华老师编写的程序源代码」· Java 代码 · 共 20 行

JAVA
20
字号
//HelloWorld2.java
public class HelloWorld2{
  public static void main (String args[ ]){
    int i =0;
    String hello[ ]= { "Hello world!", "Hi, Java!", "HELLO, WORLD!" };
    while (i<4){
      try {
        System.out.println (hello[i]);
      }
      catch(ArrayIndexOutOfBoundsException e) {
        System.out.println("The exception is caught at i = " + i);
      } 
      finally {
        System.out.println("This is always printed");
      }
      i++;
    }
  }
}

⌨️ 快捷键说明

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