I want to write a for-each loop that will print out every string in an ArrayList of Strings (called "collection"). What's the proper way to write this loop in Java?
for (String str : collection)
{
System.out.println(str);
}
-
for (collection : String str)
{
System.out.println(str);
}
-
for each (collection : String str)
{
System.out.println(str);
}
-
for each (String str : collection)
{
System.out.println(str);
}
There are not hints for this question