Comparing Class Types in Java

前端 未结 8 2036
不知归路
不知归路 2020-12-14 06:07

I want to compare the class type in Java.

I thought I could do this:

class MyObject_1 {}
class MyObject_2 extends MyObject_1 {}

public boolean funct         


        
8条回答
  •  抹茶落季
    2020-12-14 06:15

    Hmmm... Keep in mind that Class may or may not implement equals() -- that is not required by the spec. For instance, HP Fortify will flag myClass.equals(myOtherClass).

提交回复
热议问题