Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - How to use Java reflection to get the results of all get methods in an object
How to use Java reflection to get the results of all get methods in an object
Public void method (tblfwlxobj)

class clazz = obj . getclass();

Field[] fields = obj.getClass()。 getDeclaredFields(); //Get properties

For (field field: field)

property descriptor PD = new property descriptor(field . getname(),

clazz);

method get method = PD . getreadmethod(); //get the get method

object o = get method . invoke(obj); //Execute the get method and return an object.

}

}