Java error: Found interface … but class was expected

后端 未结 5 2063
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-05 00:55

I am getting a strange runtime error from my code:

\"Found interface [SomeInterface] but class was expected\"

How can this happen? How can an i

5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-05 01:23

    It sounds like you did

    class MyClass extends SomeInterface
    

    when it should actually be

    class MyClass implements SomeInterface
    

    Am I right?

    EDIT: Oh, you say it's a runtime error and not a compile-time error? Let me look around a bit...

    EDIT 2: It looks like Jared has the correct answer. Anyway, trying to extend an interface would actually give a "no interface expected here" message at compile time, not a "found interface but class was expected" error.

提交回复
热议问题