我有一个bean,我放了另一个beanlist,我想访问那个内部bean。
我的第一个豆是:
public class FirstDTO {
private String Fname= "";
private String name= "";
private List<studentTransactionDTO> studentTransactionDTOList = new ArrayList<studentTransactionDTO>();
getter and setters....
我的第二个Bean是:
public class studentTransactionDTO {
private String age= "";
private String lName = "";
private String marks = "";
getter and setters....
请给我一些从内核中检索价值的建议。
问候。
答案 0 :(得分:2)
你可以试试这种方式
FirstDTO firstDTO=new FirstDTO();// FirstDTO instance
List<studentTransactionDTO> list=firstDTO.getStudentTransactionDTOList();
// list of studentTrasactionDTO in firstDTO
String age=list.get(0).getAge(); // name of first element in list
您可以按如下方式迭代整个列表
for(studentTransactionDTO i:list){
i.getName()// you can access i's properties.
}
答案 1 :(得分:1)
FirstDTO firstDTO = new FirstDTO();
List<studentTransactionDTO> list = firstDTO.getStudentTransactionDTOList();
for(int i = 0; i < list.size(); i++){
String age = list.get(i).getAge();
}
答案 2 :(得分:1)
public studentTransactionDTO getStudentTransactionDTO(int index) {
return studentTransactionDTOList.get(index);
}
然后您可以通过以下方式访问它:
studentTransactionDTO std = firstBeanObject.getStudentTransactionDTO(0);
std.getAge();