How to iterate nested lists in java
Hi,
How to iterate nested lists in java? This is an example
private List<CustomerVO> getCustomerList(){
List<CustomerVO> list1 = new ArrayList<CustomerVO>();
List<CustomerVO> list2 = new ArrayList<CustomerVO>();
List<CustomerVO> list3 = new ArrayList<CustomerVO>();
CustomerVO customerVO1 = new CustomerVO();
customerVO1.setFirstName("Micheal")
customerVO1.setLastName("Bob")
list1.add(customerVO1);
CustomerVO customerVO2 = new CustomerVO();
customerVO2.setFirstName("Frank")
customerVO2.setLastName("Duke")
list2.add(customerVO2);
list3.addAll(list1);
list3.addAll(list2);
}
main() {
List<CustomerVO> customerList = getCustomerList();
// How to iterate and get the respective details from both List1 and List2?
for(List<CustomerVO> : customerList) // LIST1 .. this is not working
for(CustomerVO custVO1: customerList){ //LIST1 VO
..
..
}
}
Here how to get the values from list1 and list2?
Thanks.