테스트 화면
//메소드 예외처리
import java.util.Scanner;
import java.util.InputMismatchException;
class ExceptionTest3
{
int a, b, c;
//메소드 예외처리
public ExceptionTest3() throws InputMismatchException, ArithmeticException{
start();
}
public void start() throws InputMismatchException, ArithmeticException{
output();
}
public void output() throws InputMismatchException, ArithmeticException{
input();
c = a / b;
System.out.println("c = "+c);
}
public void input() throws InputMismatchException{
Scanner scan = new Scanner(System.in);
System.out.print("a = ");
a = scan.nextInt();
System.out.print("b = ");
b = scan.nextInt();
}
}
메인 화면
import java.util.InputMismatchException;
public class ExceptionTest3Main
{
public static void main(String[] args)
{
try{
ExceptionTest3 et3 = new ExceptionTest3();
}catch(Exception e){
System.out.println("예외 발생");
}
}
}
'응용 SoftWare > JAVA' 카테고리의 다른 글
[예외처리] 예외 클래스 만들기 (0) | 2016.12.05 |
---|---|
[예외처리] 예외 발생시키기 (0) | 2016.12.05 |
[예외처리] try-catch (0) | 2016.12.05 |
[익명 클래스] 팝업창(좌표) 만들기 (0) | 2016.12.05 |
[익명 클래스] 오버라이딩을 이용한 팝업창 만들기 (0) | 2016.12.05 |