简体   繁体   中英

interface class implements Runnable

there is a interface class, and an another class which implements this interface. If this interface had made as "extends Runnable", then there is a conflict in another class which implements this interface class. Why ? how may i implement the another class which implementing interface class ?

In Java, an interface can extend another interface, but an interface cannot implement another interface. You can use something like this:

YourClass implements YourInterface, Runnable { ... }

Or an alternative could be this:

YourInterface extends Runnable { ... }
YourClass implements YourInterface { ... }

There won't be any ambiguity because all the methods in interface are abstract. And that's also the reason that a class is not allowed to extend more than one class in Java.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM