+ 3
Using super. in super class
Hey, i understand that using super in subclass refers to it's super class but then if you use super in super class why does it seem to refer to its self and not ObjectClass or is it?? When calling super.getClass().getName(); in super class it returns my superclass and not ObjectClass which I was expecting? I have searched about but only find what super means in sub class 😅 thanks
3 Antworten
+ 3
Maybe this helps you to understand:
https://stackoverflow.com/questions/34893848/in-java-super-getclass-prints-an-unexpected-name-in-the-derived-class-why-is?noredirect=1&lq=1
+ 4
Denise Roßberg Perfect! super.getName().getSuperclass(); got me what I needed 👍👍👍
+ 3
Very interesting question.
I have found this article about calling super():
https://stackoverflow.com/questions/12066984/java-does-object-class-have-a-constructor
The object class has a constructor but I think it is not possible to show it on sololearn that you are really calling the constructor of the object class.
About calling super.getClass().getName():
I need more time for research. I can not explain why it prints the name of the current class and not of object class.