We are using below code for getting variable name
public void printFieldNames(Object obj, Foo... foos) {
List<Foo> fooList = Arrays.asList(foos);
for(Field field : obj.getClass().getFields()) {
if(fooList.contains(field.get()) {
System.out.println(field.getName());
}
}
}
But some object contains another object for example
class A{
String a="nil";
B b;
}
class B{
int n1=0;
}
How to get object b varable details?
How to get custom list class name and object?
We need to get any object details assuming we don't know class name and inner object name