Java: custom-exception-error

Posted by HH on Stack Overflow See other posts from Stack Overflow or by HH
Published on 2010-04-13T16:35:30Z Indexed on 2010/04/13 16:43 UTC
Read the original article Hit count: 379

$ javac TestExceptions.java 
TestExceptions.java:11: cannot find symbol
symbol  : class test
location: class TestExceptions
            throw new TestExceptions.test("If you see me, exceptions work!");
                                    ^
1 error

Code

import java.util.*;
import java.io.*;

public class TestExceptions {
    static void test(String message) throws java.lang.Error{
        System.out.println(message);
    }   

    public static void main(String[] args){
        try {
             // Why does it not access TestExceptions.test-method in the class?
            throw new TestExceptions.test("If you see me, exceptions work!");
        }catch(java.lang.Error a){
            System.out.println("Working Status: " + a.getMessage() );
        }
    }
}

© Stack Overflow or respective owner

Related posts about java

Related posts about beginner