I wanted to ask that how to mention this in my interface
public class find(int x) throws A_Exception, B_Exception{
----
----
---
}
i want to say that i can mention One exception in an interface but how to mention in my interface that my method will throw Two exceptions Namely A and B…
the code fragment mentioned above works only for A and not for B… Help
public interface dictionary{
public void insert(int x) throws Dictionary_FullException, Duplicate_Element_FoundException;
}
...
public class SortedArray implements dictionary{
public void insert(int x) throws Dictionary_FullException, Duplicate_Element_FoundException {
---------
}
but when i compile it … it says..
SortedArray.java:66: insert(int) in
assign.SortedArray cannot implement
insert(int) in assign.dictionary;
overridden method does not throw
assign.SortedArray.Duplicate_Element_FoundException public
void insert(int x) throws
Dictionary_FullException
You can declare as many Exceptions as you want for your interface method. But the class you gave in your question is invalid. It should read
Then an interface would look like this