For & For each loop code example
Example 1: java for each
//itemset contains variables of type <Data Type>
for(<Data Type> item : itemset) {
//loop
}
Example 2: enhanced for loop java
class AssignmentOperator {
public static void main(String[] args) {
char[] vowels = {'a', 'e', 'i', 'o', 'u'};
// foreach loop
for (char item: vowels) {
System.out.println(item);
}
}
}