Monday, May 9, 2011

The code below leads to an error "interface expected here"

public interface MyInterface extends Thread

Here an interface is created (MyInterface) and it inherits(extends) the Thread class which is not possible at all. Why? Because an interface can inherit only another interface, not any class. As Thread is a class, it cannot be inherited by any interface.

The code below is correct as the interface inherits another interface Runnable

public interface MyInterface extends Runnable

A similar type of error is posted at  no interface expected here

If the above solutions do not work for you. Please comment below giving your code. I'll try to respond.


Post a Comment