new for loop java code example
Example 1: java for loop
for(int i = 0; i < 10; i++)
{
}
Example 2: Java for loop
int values[] = {1,2,3,4};
for(int i = 0; i < values.length; i++)
{
System.out.println(values[i]);
}
Example 3: enhanced for loop java
class AssignmentOperator {
public static void main(String[] args) {
char[] vowels = {'a', 'e', 'i', 'o', 'u'};
for (char item: vowels) {
System.out.println(item);
}
}
}
Example 4: enhanced for loop java
class ForLoop {
public static void main(String[] args) {
char[] vowels = {'a', 'e', 'i', 'o', 'u'};
for (int i = 0; i < vowels.length; ++ i) {
System.out.println(vowels[i]);
}
}
}