There are 2 interfaces:
public interface A {
ArrayList<Integer> all() throws ExceptionA;
}
public interface B {
List<String> all() throws ExceptionB;
}
And there is class that implements them:
public class C implements A, B {
@Override
public ArrayList all() {
return null;
}
}
Also checked exceptions:
public class ExceptionA extends Exception {
}
public class ExceptionB extends Exception {
}
When I compile this code everything is OK. Why?
I know that in implementation we can use subtype (in this situation ArrayList is subtype of List). But I have next questions:
- Why in implementation you can omit throws part? In interface methods there are throws parts of checked exceptions
- Why in implementation you can omit generic type?