I believe in other languages, you can do the following:
for (String foo : new String[]{"string1", "string2", "string3"}) {
//do something with foo
}
However with Java, I get an error with
new String[]{"string1", "string2", "string3"}
Is something like this possible in Java, or do I have to create the new array like so:
final String[] bar = {"string1", "string2", "string3"};
for (String foo : bar) {
//do something with foo
}