- 博客(3)
- 收藏
- 关注
原创 数组中获取第二大的数
1个数组 获取数组中第二大的数字 (限制:只能一个for循环,不能排序) public int findSecondBigNum(int[] nums){ int max = 0, second = 0; for(int item : nums){ max = item > max ? item : max; second = (item > second && item < max) ? i
2020-09-16 23:29:26
564
原创 java8利用Stream统计字符串中各个字符出现次数
话不多说 上代码 String str = "abjdskajdklwqklwjkasljdksal"; Map<String, Long> collect = Stream.of(str.split("")).collect(Collectors.groupingBy(String::toString, Collectors.counting())); System.out.println(JSON.toJSONString(collect)); 完事儿!
2020-09-14 21:28:43
3322
原创 java8-stream排序去重等操作
找出list对象中某个字段重复的值对List对象集合某个字段进行排重根据list对象中的两个字段进行排序,字段有空的就放最后 List<String> list =orderList.stream(). collect(Collectors.groupingBy(OrderViewModel::getPcno,Collectors.counting())) .entrySet().stream() .filter(entry
2020-07-24 16:28:29
1232
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人