foreach - Is there something better than a For loop in Java for iterating neatly through a collection? -
I have been screwed with C # along with Foreach, is there anything like this for Java?
Yes, which was introduced in Java 1.5:
List & lt; String & gt; String = getStringsFrom (from somewhere); For (string x: strings) {System.out.println (x); } This array and Iterable & lt; T & gt; Anything that implements (or raw Iterable type) works.
Comments
Post a Comment