maybe, you forget try...catch... , since the contructor throws an exception.


try {
        MyClass oneclass = new MyClass("Test",1);
}
catch(Exception e) {}


>Hi,
>
>I have a class with one contructor that throws an exception, e.g.:
>
>    public MyClass(String str, int type) throws Exception
>    {
>            public int  myMethod(int i) {return i;};
>    }
>
>When I try to override one of its methods, e.g.:
>
>    oneclass=new MyClass("Test", 1)
>        {
>            public int myMethod(int i) {return i++; }
>        }
>
>I get the following compilation error:
>
>    Error #: 360 : unreported exception: java.lang.Exception; must be
>caught or declared to be thrown at line 32, column 28
>
>Is there a way to do this, excluding the posibility to extend the class?
>
>Thanks in advance,
>
>David
>
>P.S. Sorry if this msg was an off-topic, but I don't like to be
>subscribe in many java lists, and because I am working only with
>servlets, I am subscribed only to this java list :-)
>
>___________________________________________________________________________
>To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
>of the message "signoff SERVLET-INTEREST".
>
>Archives: http://archives.java.sun.com/archives/servlet-interest.html
>Resources: http://java.sun.com/products/servlet/external-resources.html
>LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to