I tried this in Eclipse and it shows a compile error. However trying the same in the online IDE Compilr showed no errors. That’s why the confusion.
interface Iclass{
void print();
void hey();
}
class sdlfkajl implements Iclass {
public void print(){
System.out.println("Impl class");
}
public void hey(){
System.out.println("Hey!");
}
public void extra(){
System.out.println("Should I be here?");
}
}
The error shown is that this class cannot have methods not declared in the interface. Suggestion tooltip said I should declare this method in the interface too.
There is no error in your code.
You might be mistaking a warning for an error – IntelliJ can be set to flag the code above as a warning.
You might also have a setting for warnings to fail the compile.
So check your IDE settings!