How would you write this for-each loop a different way so as to not incorporate the ":"?
Assuming that list
is a Collection
instance ...
public String toString() {
String cardString = "";
for (Iterator<PlayingCard> it = this.list.iterator(); it.hasNext(); /**/) {
PlayingCard c = it.next();
cardString = cardString + c + "\n";
}
}
I should add the pedantic point that :
is not an operator in this context. An operator performs an operation in an expression, and the stuff inside the ( ... )
in a for
statement is not an expression ... according to the JLS.