I am inside a subclass and when I am trying to find the name of super class, I tried super.getClass() , but it is returning me the name of the subclass only. Why?
相关问题
- 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
This is because you are creating object of derived class and not super class.. you may try this
getClass().getSuperclass()
should do.If you override a method from your superclass (or your superclass's superclass etc.),
super.theMethod()
will invoke the original method instead of the one you overrode it with. If you did not actual overridetheMethod
,super.theMethod()
will act exactly liketheMethod()
.In this case I assume you did not override
getClass()
(in fact I know you didn't because it's final), sosuper.getClass()
acts exactly likegetClass()
, i.e. either way thegetClass
method of theObject
class is called.