Search code examples
javalinqscalaclosuresjava-7

Is there something like LINQ for Java?


Started to learn LINQ with C#.
Especially LINQ to Objects and LINQ to XML.
I really enjoy the power of LINQ.

I learned that there is something called JLINQ a JavaScript implementation.
Also (as Catbert posted) Scala will have LINQ

Do you know if LINQ or something similar will be a part of Java 7?

Update: Interesting post from 2008 - LINQ for Java tool


Solution

  • Look at Scala, which is powerful functional programming language, but is similar to Java and runs on Java platform.

    In Scala it is possible to use essentially the same code constructs as in LINQ, albeit without special query comprehensions syntax present in C# or VB.

    EDIT :

    Here's an example of Scala's querying capabilities :

    // Get all StackOverflow users with more than 20,000 reputation points.
    val topUsers = for{
        u <- users
        if u.reputation > 20000
    } yield u;
    
    println ("Users with more than 20,000 reputation:")
    for (u <- topUsers) {
        println u.name
    }