No, the closest will be:
for (Integer item : group<Integer>) { if (item <= 5) { break; }
Of course, if Java ever gets a brief closure, it would be wise to write something like .NET Enumerable.TakeWhile to wrap iterable ( group in this case) and exit earlier if the condition no longer holds.
This can be done now, of course, but the code for this would be ugly. For reference, C # will look like this:
foreach (int item in group.TakeWhile(x => x > 5)) {
Maybe Java will soon become a good closure ...
Jon skeet
source share