I know the class name, say "MyClass" and want to retrieve the Class object, ie. MyClass.class for future references. Is there a way to do that?
I've looked through the web but ...
I want to get an array(or list) of a POJO's property names .
I tried commons-beanutil's BeanUtils.describe(obj) , but it needs an object instance.
But what if I only have that class , ...
Object o = ...; // The object you want to inspect
Class<?> c = o.getClass();
Field f = c.getDeclaredField("myColor");
f.setAccessible(true);
String valueOfMyColor = (String) f.get(o);