It's UWAweek 17 (1st semester, week 8)

help2005

This forum is provided to promote discussion amongst students enrolled in CITS2005 Object Oriented Programming.

Please consider offering answers and suggestions to help other students! And if you fix a problem by following a suggestion here, it would be great if other interested students could see a short "Great, fixed it!"  followup message.

How do I ask a good question?
Displaying selected article
Showing 1 of 85 articles.
Currently no other people reading this forum.


 UWA week 12 (1st semester, week 4) ↓
SVG not supported

Login to reply

👍x1
helpful
9:40am Mon 18th Mar, ANONYMOUS

emails is an array (or specifically an ArrayList) of objects of the class Email. The loop is a 'for-each' loop which uses the syntax:

for (datatype variableName : collection) { 
    ...
}

This means: for each item in the collection/array, store the item of type datatype in the variable called variableName. This variable can be used within the body of the for-each loop, which is executed for each item in the array.

For example:

int[] arrayOfAges = {18, 22, 21, 19, 27};

for (int age : arrayOfAges) {
    System.out.println(age)
}

Will produce the following output:

18
22
21
19
27

So the for (Email email : emails) means get each Email object in the ArrayList emails and store a reference to that object in the variable email.

The University of Western Australia

Computer Science and Software Engineering

CRICOS Code: 00126G
Written by [email protected]
Powered by history
Feedback always welcome - it makes our software better!
Last modified  5:07AM Sep 06 2023
Privacy policy