QUESTION

In this exercise, rewrite the for loop in the starter code, which prints out the odd numbers in an array, as an enhanced for-each loop.

public class PrintOdds
{
public static void main(String[] args)
{
int[ ] values = {17, 34, 56, 2, 19, 100};

for (int i = 0; i < values.length; i++)
{
if (values[i] % 2 == 1)
System.out.println(values[i] + " is odd");
}
}
}

Public Answer

1DZGXQ The First Answerer