Java8的stream API与 C#的 LINQ 拓展方法对比
为方便初学 Java8/C# 集合操作的人,特意写下这篇文章. 前期准备 C#版 java版 单集合 分类筛选 计数(Count) Date time1 = convertLocalDateToTimeZone(LocalDate.of(1990, 1, 1)); //0 Long count1 = list1.stream().filter(o -> o.getBirthday().equals(time1)).count(); int count1 = list1.Where(o => o.Birthday.Equals(new DateTime(1990, 1, 1)) && o.Sex == Sex.Male).Count(); long count2 = list1.Where(o => o.Birthday.Equals(new DateTime(1990, 1, 1)) && o.Sex == Sex.Male).LongCount(); /* 0 0 */ 分组(GroupBy) Map<Sex, List<...