매니저/JAVA1

JAVA1 Exception 예제1 (임시저장)

cdprkr2077 2011. 12. 23. 20:56


// 예외가 발생되는 예

class  ExceptionEx1
{
 public static void main(String[] args)
 {
  int m[] = { 10, 20, 30 };

  try
  {
   for( int i = 0; i < m.length + 1; i++ )
   {
    System.out.println( "m[" + i + "] : " + m[i] );
   }

   System.out.println( "프로그램 끝" );
  } catch( ArrayIndexOutOfBoundsException e )
  {
   System.out.println( "배열의 범위를 넘었다" );
   e.printStackTrace();
  } finally
  {
   System.out.println( "프로그램 끝" );
  }
 }
}