How this for loop statement works? Can we only use it to print arrays?
for (Integer i : arrayToSort){
System.out.println(i.intValue());
}
How this for loop statement works? Can we only use it to print arrays?
for (Integer i : arrayToSort){
System.out.println(i.intValue());
}
This is the for-each loop, you can use it like the normal for-loop. Only the syntax is different. Please look at the https://docs.oracle.com/javase/8/docs/technotes/guides/language/foreach.html