6.3

Enhanced for Loop

AP Computer Science A

Syntax

How it works

Key examples

Sum all elements

Find the maximum

Count matching elements

With String arrays

The copy trap (cannot modify array elements)

Exception: Object references

When to use which loop

Examples of when you NEED a standard for loop

Complete example: Grade report

AP Exam Tips

Common Mistakes

Key Vocabulary