Well, ok, I guess I havent any experience creating anonymous classes, so i'll take what
you say for granted.. However, is there any reaosn why you *have to* use anonymous
classes and not just go the the "normal" subclassing route?..
Geeta
P.s. Also now it seems to me that this is a more general Java question, so maybe you
could check the archives/post the question in the Java list? you may strike lucky
there..!
David V�squez Estrada wrote:
> Hi Geeta,
>
> > Please correct me if I misunderstand you, but here's what it seems you are doing:
> >
> > 1. Create a class MyClass with a public method myMethod and a constructor which
> > throws an exception.
>
> correct
>
> > 2. Create an *object* oneclass of class MyClass. You havent stated that oneclass is
> > actually of class MYClass but i assume it has to be since you are using MyClass's
> > constructor.
>
> correct
>
> > (I don't see any inner or subclass here and therefore fail to see what
> > overriding you are talking about..)
>
> Well, the problem is that I need to override a method of the class MyClass, creating
> an anonymous class, if the constructor of this class does not throws an exception, I
> can do the following with out problems:
>
> oneclass=new MyClass("Test", 1)
> {
> public int myMethod(int i) {return i++; }
> }
>
> But, if the constructor throws an exception the code above is not correct for the
> compiler, even if I make the following:
>
> try{
> oneclass=new MyClass("Test", 1)
> {
> public int myMethod(int i) {return i++; }
> }
> }
> catch(Exception e){
> //deal with the exception here..
> }
>
> I don't why this is not possible, and there is no documentation about that.
>
> David
>
> ___________________________________________________________________________
> 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