Fundamentals5 / 25
Up next

Enhanced for

class Main {
    public static void main(String[] args) {
        String[] colors = {"red", "green", "blue"};
        // reads each element in turn
        for (String color : colors) {
            System.out.println(color);
        }
    }
}
What you're solving

iterate elements without an index