How to determine an object's class?

后端 未结 11 1158
醉酒成梦
醉酒成梦 2020-11-22 17:10

If class B and class C extend class A and I have an object of type B or C, how can I determine of which type

11条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-22 17:23

    I use the blow function in my GeneralUtils class, check it may be useful

        public String getFieldType(Object o) {
        if (o == null) {
            return "Unable to identify the class name";
        }
        return o.getClass().getName();
    }
    

提交回复
热议问题