while loop to traverse an integer arraylist in java code example
Example 1: loop through an arraylist android studio
List<MyObject> AllData = dataBaseHelper.getAllData(); //initialize
for (MyObject obj : AllData) { //loop
if (obj.getNum() == num) { //condicion
//code
}
}
Example 2: enhanced for loop arraylist
// for(dataType var: myArrayList){
// System.out.println(var);
// }
for(int num: numList){
System.out.println(num);
}