【Java】【代码优化】+try catch 异常
示例代码
public class test { public static void tryCatch(){ String a = null; try { System.out.println(a.equals("aa")); }catch (Exception e){ System.out.println("try1"); } try { System.out.println(a.equals("aa")); }catch (Exception e){ System.out.println("try2"); } System.out.println(a.equals("aa")); System.out.println("aaaaaa"); } public static void main(String[] args) { tryCatch(); } }
如果忍耐算是坚强 我选择抵抗 如果妥协算是努力 我选择争取