Try
-
[JAVA] try-catch 문JAVA 2023. 7. 13. 23:10
프로그램 실행 중에 발생하는 에러(익셉션: exception,예외)를 처리하는 방법 /* try문의 기본 형식 */ try try 블록 catch(익셉션타입 익셉션변수) catch 블록 finally finally 블록 /*try-catch*/ public class Test { public static void main(String[] args) throws Exception { int num1=2; int num2=3; int num3=0; int result; try{ result = num1+num2; System.out.println("result:" + result); }catch (java.lang.Exception e){ System.out.println("잘못된 연산입니다."); } //..