Hi, I am doing URLyBird and want to extend the "DBMain" interface, but I have one problem about adding more exceptions in the extending interface. For example, say I have the following interfaces:
This gives a compile error complaining that overriden method does not throw RecordNotFoundException. But if I put for example IOException instead of RecordNotFoundException:
This compiles and I don't know exactly why. Can somebody tell me why this is so? Thanx in advance! Kim
posted 13 years ago
Hi Kim, There is an overriding rule that you don't follow in your first example: The overriding method must not throw any new or broader checked exception, though it can throw narrower or fewer exceptions. The second example compiles because RemoteException is an IOException (a narrower one). Regards, Phil. [ March 20, 2004: Message edited by: Philippe Maquet ]
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads