import java.io.File;
import java.lang.reflect.Field;
import java.util.ArrayList;
import org.junit.experimental.theories.Theories;
import org.omg.CORBA.PUBLIC_MEMBER;
import com.bjsxt.model.User;
public class parseBean {
public static <E> void parse(ArrayList<E> infBean, String name)
throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
// TODO Auto-generated method stub
Field field;
for (E e : infBean) {
field = e.getClass().getDeclaredField(name);
field.setAccessible(true);
Object kk = field.get(e);
System.out.println(kk.toString());
}
}
public static void main(String[] args)throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
User user = new User();
user.setUsername("123");
ArrayList<Object> userList = new ArrayList<Object>();
userList.add(user);
parse(userList, "username");
}
}
import java.lang.reflect.Field;
import java.util.ArrayList;
import org.junit.experimental.theories.Theories;
import org.omg.CORBA.PUBLIC_MEMBER;
import com.bjsxt.model.User;
public class parseBean {
public static <E> void parse(ArrayList<E> infBean, String name)
throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
// TODO Auto-generated method stub
Field field;
for (E e : infBean) {
field = e.getClass().getDeclaredField(name);
field.setAccessible(true);
Object kk = field.get(e);
System.out.println(kk.toString());
}
}
public static void main(String[] args)throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
User user = new User();
user.setUsername("123");
ArrayList<Object> userList = new ArrayList<Object>();
userList.add(user);
parse(userList, "username");
}
}