Discuss / Java / 练习:抛出异常

练习:抛出异常

Topic source

jasmine

#1 Created at ... [Delete] [Delete and Lock User]
try {
    int c = stringToInt(a);    
    int d1 = stringToInt(b);    
    System.out.println(c * d1);
} catch (NumberFormatException e) {
    System.out.println("Number not Format");} catch (Exception e) {
    System.out.println(e);
}

jasmine

#2 Created at ... [Delete] [Delete and Lock User]

说错了,是捕获异常

🌙

#3 Created at ... [Delete] [Delete and Lock User]

catch (Exception e) {
System.out.println("以外错误!!!");
}

还不忘加上 这个 点赞


  • 1

Reply