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

后端 未结 7 1808
盖世英雄少女心
盖世英雄少女心 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:07

    You can do:

    if (foo instanceof classNameYouWantToCheck) 
    
    0 讨论(0)
提交回复
热议问题