KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm trying to achieve some sort of reflection in java. I have: class P { double t(double x) { return x*x; } double f(String name, double x) { Method method; Class<?> enclosingClass = getClass().getEnclosingClass(); if (enclosingClass != null) { method = enclosingClass.getDeclaredMethod(name, x); try { method.invoke(this, x); } catch (Exception e) { e.printStackTrace(); } } } class o extends P { double c() { return f("t", 5); } } How do I get value from new o().c()?
Tags (comma-separated)
Save Edits
Cancel