variable 'size' is the size of the larger list.
for(int x = 0; x < size; x++){
if(employees!= null && employees.size() > x){
//do something
}
if(consultants!= null && consultants.size() > x){
// do something
}
Then i have another way of doing it
for(Object obj : employees){
//do something
}
for(Object obj : consultants){
//do something
}
The second approach seems simpler to me, but the first approach would result in lower loop iterations. anyways, i would like to know which would be better in a general situation.
Aucun commentaire:
Enregistrer un commentaire