package com.js.s;
import java.lang.reflect.InvocationTargetException;
public class meiju {
public static void main(String[] args) throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException{ c model = new c(); meiju output = new meiju(); output.AllByType(model); output.AllByObject(model); output.allByGet(model); }//根据类型来遍历对象的属性public void AllByType(c model) throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException{ System.out.println("根据类型来遍历对象的属性"); java.lang.reflect.Field[] field = model.getClass().getDeclaredFields(); //获取实体类的所有属性,返回Field数组 for(int j=0 ; j
}
class c{
public String k = "10"; public int age = 20;public String getK() { return k;}public void setK(String k) { this.k = k;}public int getAge() { return age;}public void setAge(int age) { this.age = age;}
}