티스토리 뷰

dev/java

[15] 예외 발생 시키기

altvirus 2008. 9. 29. 13:12
import java.io.*;

public class _4_1 {
	public static void main(String[] args)  throws Exception{
		
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		
		int su1 = 0;
		
		System.out.print("su1 = ");
		su1 = Integer.parseInt(in.readLine());
		
		if(su1 > 100){ // 강제적으로 예외 발생
			System.out.println("예외 발생 :");
			Exception ex = new Exception(">100");
			throw ex;
		}
		
	}
}
공지사항