Comparing two classes by its types or class names

前端 未结 7 1187
耶瑟儿~
耶瑟儿~ 2021-02-01 15:34

There is need to compare two objects based on class they implement? When to compare using getClass() and when getClass().getName()? Is there any differ

7条回答
  •  时光说笑
    2021-02-01 15:53

    if you have an array to compare then use below

    array.getClass().getComponentType() == X.class
    

提交回复
热议问题