I have the following method and I need to return two strings:
- value of type.getName()
- value of field.getName()
What is the best way to do it?
public static void getClassMetaData(List<Object> listClsObj) {
....
for (Field field : declaredFields) {
Class<?> type = field.getType();
System.out.println(type.getName());
System.out.println(field.getName());
}
}
I would rather return just the
Field, since you can get thetypeand other information from thefielditself.And then at the point of invocation, call the method –
field.getType()to get the type.Seems like you are working with all the declared fields of your class, in which case you can just return the
List<Field>: –