在java中实现这个linq查询的最简单方法是什么?

问题描述:

我有C#代码,它接受字典值,对它们进行排序并转换成列表(使用Linq)。我想知道如何用Java做同样的事情(更喜欢最简单的方法)。



I have C# code that takes values of dictionary, sorts them and turns into list (using Linq). I would like to know how to do the same thing in Java (prefer most simple way).

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Test
{
    class Test
    {
        static void Main() {
            Dictionary<string, string> wars = new Dictionary<string,string> () {
                {"WWI","1914-1918"}, {"WWII","1939-1945"}, {"Vietnam War","1955-1975"}
            };

            var query=(from item in wars orderby item.Value descending select item.Value).ToList();

            foreach (var i in query) {
                Console.WriteLine (i);
            }
        }
    }





我尝试了什么:



试过谷歌,但没有找到简单的解决方案。



What I have tried:

Tried to Google, but didn't found simple solution.

我想知道你搜索了什么对于Google,我第一次发现:集合(Java Platform SE 7) [ ^ ]。
I wonder what you searched for in Google, I found this first time: Collections (Java Platform SE 7 )[^].


嗨好友检查这个关于java中linq查询的有用链接



LINQ for Java:Quaere [ ^ ]



Linq查询入门 [ ^ ]



LINQ的最佳Java等效项(C#)|丰富的代码 [ ^ ]



我希望它能帮到你
Hi buddy check this useful link about linq query in java

LINQ for Java: Quaere[^]

Getting Started with Linq Queries[^]

Best Java Equivalent for LINQ (C#) | Abundant Code[^]

I hope it will help you


AFAIK,Java没有LINQ的等效设施。



LINQ代码只返回按值排序的列表(每个项目中的日期范围)。 Java有它自己的排序方法。
AFAIK, Java doesn't have an equivilent facility to LINQ.

That LINQ code just returns the list sorted by Value (the date range in each item). Java has it's own sort methods.