1

If I write RunTimeException in catch block then why it is not handled.

class main{
    public static void main(String cs[]){
        try{
            int a = 10/0;
        }
        catch(RunTimeException e){
            System.out.println("exception caught");
        }
    }
}

My question is why there is an error if I write RunTimeException and not in case if I write the subclass of RunTimeException i.e ArithmaticException and super class Exception.

error is

Exception in thread "main" java.lang.Error: Unresolved compilation problem: 
RunTimeException cannot be resolved to a type
4

2 に答える 2

8

これは、RunTimeException ではなく、RuntimeException です。Java は大文字と小文字を区別する言語です。

于 2013-04-04T07:55:42.883 に答える