What is the Java equivalent for LINQ?

什么是Java相当于LINQ?


There is nothing like LINQ for Java.

...

Edit

Now with Java 8 we are introduced to the Stream API, this is a simular kind of thing dealing with collections, but it is not quite the same as Linq.

If it is a ORM you are looking for like Entity Framework, then you can try Hibernate

:-)


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/52946.html

上一篇: C#中的一个未知功能可能只是为了我

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