Have a look at this C # code example:
List<int> numbers = new List<int>() { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 };
int numCount = numbers.Where(n => n < 3 || n > 7).Count();
I am sure that the explicit Java equivalent is that you donβt explicitly need to write fancy for foreach loops to iterate through the collection.
As far as I know, Java doesn't have exact linq equivalence, but I'm still new to Java programming, so what can you recommend to me? I'm actually looking for the most compact and elegant way to achieve the same result in Java
[added] So, thanks for all the answers. However, I need to use it on Android, and it seems like I can't. Is there any solution for this?
(sorry, it is duplicated)
[added] Has anyone tried this?
http://sourceforge.net/projects/streamsupport/