Reputation: 163
I've made a more specific ListIterator for singly linked lists and I have implemented most of the methods. I see in the description that some methods should throw exceptions but some exceptions don't seem particularly relevant, especially as I'm using generics. Is it fine to not have these exceptions in the implementation?
Upvotes: 4
Views: 213
Reputation: 1075019
Fundamentally, since the throws
isn't part of the method signature, if your implementation of a method doesn't throw the relevant exception, you can leave that exception off.
E.g., this is perfectly valid:
public interface MyInterface {
void method() throws Exception;
}
and
public class Example implements MyInterface {
public void method() {
}
}
Upvotes: 4