67,513
社区成员
发帖
与我相关
我的任务
分享
public static void main(String[] args) {
method();
}
public static void method() {
for (int i = 0; i < 10; i++) {
try {
int k = 10 / i;
System.out.println(k);
} catch (Exception e) {
e.printStackTrace();
continue;
}
}
}
public static void main(String[] args) {
int i = 0;
String[] s = { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11" };
System.out.println(loop(i, s));
}
public static boolean loop(int i, String[] s) {
try {
for (int iSize = s.length; i < iSize; i++) {
if (i == 5) {
throw new Exception(i + ":这里抛出异常!");
}
System.out.println(i + ":" + s[i]);
}
} catch (Exception e) {
loop(i + 1, s);
return false;
}
return true;
}