KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have two classes: public class A { public Object method() {...} } public class B extends A { @Override public Object method() {...} } I have an instance of B . How do I call A.method() from b ? Basically, the same effect as calling super.method() from B . B b = new B(); Class<?> superclass = b.getClass().getSuperclass(); Method method = superclass.getMethod("method", ArrayUtils.EMPTY_CLASS_ARRAY); Object value = method.invoke(obj, ArrayUtils.EMPTY_OBJECT_ARRAY); But the above code will still invoke B.method() .
Tags (comma-separated)
Save Edits
Cancel