What is the Java equivalent for LINQ?

什么是Java相当于LINQ?


没有什么像Java的LINQ。


There is an alternate solution, Coollection.

Coolection has not pretend to be the new lambda, however we're surrounded by old legacy Java projects where this lib will help. It's really simple to use and extend, covering only the most used actions of iteration over collections, like that:

from(people).where("name", eq("Arthur")).first();
from(people).where("age", lessThan(20)).all();
from(people).where("name", not(contains("Francine"))).all();

Lambdas are now available within Java 8 in the form of JSR-335 - Lambda Expressions for the JavaTM Programming Language

UPDATE : JDK8 has now been released which contains project lambda. It's worth grabbing a copy of Java 8 in Action currently still MEAP.

Have a read of Brian Goetz articles relating to lambdas for a decent understanding of how lambdas are implemented within JDK8 while also gaining an understanding of streams, internal iteration, short-circuiting and constructor references.. Also check out the JSR's above to get further examples.

I've written a blog on some of the advantages of using lambdas in JDK8 called The Power of the Arrow, also NetBeans 8 has great support for converting constructs to JDK8 which I've also blogged about Migrating to JDK 8 with NetBeans.

链接地址: http://www.djcxy.com/p/5856.html

上一篇: 在LINQ中分组

下一篇: 什么是LINQ的Java等价物?