Я хотел бы знать, как можно обнаружить ошибку в Java, но позвольте программе продолжить работу.
Вот мой пример:
public class test1 {
public static void main(String[] args) {
String str = new String("abcdefghij");
try {
System.out.println(str.charAt(0));
System.out.println(str.charAt(9));
System.out.println(str.charAt(10));
System.out.println("is it still running");
} catch (Exception e) {
System.out.println("the index is out of bounds");
}
}
}
напечатано следующее:
a
j
the index is out of bounds
но после выдачи ошибки я хотел бы, чтобы код продолжал выполняться, чтобы это печаталось:
a
j
the index is out of bounds
is it still running
заранее спасибо