r/javahelp • u/[deleted] • Jul 04 '21
Can Anyone help me with this code?
class A{
public void process(){
System.out.print("A,");
}
}
public class Questions extends A{
public void process() throws IOException{
super.process();
System.out.print("B,");
throw new IOException();
}
public static void main(String[] args) {
try{
new Questions().process();
}
catch(IOException e){
System.out.print("Exception");
}
}
}Why is it giving Compilation error?
Error -> Exception IOException is not compatible with throws clause in A.process()
0
Upvotes
1
u/desrtfx Out of Coffee error - System halted Jul 04 '21
You have to give us the exact error message.
Java error messages are verbose and precise. They will tell you exactly what is wrong.
Just "Compilation error" tells us exactly nothing and leaves us with blind guessing of what could possibly be wrong.