Loops Flashcards
1
Q
Which interface must be implemented to allow an object to be iterated by a “for-each” loop?
A
Iterable<T>
2
Q
What is the equivalent code for: Iterable.forEach(Consumer action)
?
A
for(var e : obj) { action.accept(e); }
3
Q
- What is the syntax of a for loop?
- Can a for loop have multiple initializers?
- Is “init” reinitialized for each iteration?
A
for(init; expression; inc) {...}
- Yes
- No, only initialized once