Is there something like instanceOf(Class<?> c) in Java?

后端 未结 7 1918
盖世英雄少女心
盖世英雄少女心 2020-11-27 17:15

I want to check if an object o is an instance of the class C or of a subclass of C.

For instance, if p is of clas

7条回答
  •  悲哀的现实
    2020-11-27 18:06

    I think you're confused about instanceof for raw objects and generic ones

    obj instanceof Class
    obj instanceof Class // this is the one you want
    

提交回复
热议问题