I'm trying to get the name of a type (which is an interface) that is instantiated within a class but the available methods I've tried do not return the actual name of the type.
Example:
To get the name I would do:
class Test {
void test(Object o) {
System.out.println(o.getClass());
}
}
Taking the java.lang.Runnable interface for example:
...
test(new Runnable() {});
Would print out something like class test.Test$2
, I've tried other methods in the Class class but they just print out null or test.Test
. How would I be able to get class java.lang.Runnable
from it?
Thanks!