搜题
问题   更新时间2023/4/3 12:59:00

试写出下面这个程序的执行结果.
class ExceptionTest {
static String a[] = {"123", "abc", null};
public static void main (String args[]) {
for (int i = 0; i < 3; i++) {
try {
int x = Integer.parseInt(a[i]);
System.out.println( "Result: " + x);
}
catch(NullPointerException e) {
System.out.println("error null:");}
catch (NumberFormatException e)
{System.out.println("error:abc" );}

finally{System.out.println ("In "+ i +"th loop\n"); }
} //end for
}
}

您的答案: Result: 123 In 0th loop error:abc In 1th loop error abc:In 2th loop
王老师:19139051760(拨打)