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 it is an instance?
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
Any use of any of the methods suggested is considered a code smell which is based in a bad OO design.
If your design is good, you should not find yourself needing to use
getClass()
orinstanceof
.Any of the suggested methods will do, but just something to keep in mind, design-wise.