「Java入門」getDeclaredFields()でFieldの一覧を取得するサンプル
Javaコード
import java.sql.Timestamp;
public class Employee {
private int id;
private int age;
private String stuName;
private Timestamp birthdate;
public String identitify;
protected String address;
String phone;
}
@Test
public void sampleGetDeclaredFields() {
Field[]fields=Employee.class.getDeclaredFields();
for (int i = 0; i < fields.length; i++) {
Field field = fields[i];
System.out.println(field.getName());
}
}