Java 示例 - 处理检查异常 问题描述 如何处理检查异常? 解决方案 此示例显示如何使用 catch 块处理已检查的异常。 public class Main { public static void main (String args[]) { try { throw new Exception("throwing an exception"); } catch (Exception e) { System.out.println(e.getMessage()); } } } 复制 结果 上面的代码示例将产生以下结果。 throwing an exception 复制