当前位置: 首页 > news >正文

最好的网站建设多少钱网页设计教程教学目的

最好的网站建设多少钱,网页设计教程教学目的,环艺做网站,北京服装网站建设01.收集(collect) collect#xff0c;收集#xff0c;可以说是内容最繁多、功能最丰富的部分了。 从字面上去理解#xff0c;就是把一个流收集起来#xff0c;最终可以是收集成一个值也可以收集成一个新的集合。 collect主要依赖java.util.stream.Collectors类内置的静态方…01.收集(collect) collect收集可以说是内容最繁多、功能最丰富的部分了。 从字面上去理解就是把一个流收集起来最终可以是收集成一个值也可以收集成一个新的集合。 collect主要依赖java.util.stream.Collectors类内置的静态方法。 这个是stream中的collect方法 R, A R collect(Collector? super T, A, R collector);02.归集(toList/toSet/toMap) 因为流不存储数据那么在流中的数据完成处理后需要将流中的数据重新归集到新的集合里。 toList、toSet和toMap比较常用另外还有toCollection、toConcurrentMap等复杂一些的用法。 ListInteger list Arrays.asList(1, 6, 3, 4, 6, 7, 9, 6, 20);ListInteger listNew list.stream().filter(x - x % 2 0).collect(Collectors.toList());System.out.println(产生的新集合是 listNew);SetInteger set list.stream().filter(x - x % 2 0).collect(Collectors.toSet());System.out.println(产生的不重复的新集合是 set);ListPerson personList new ArrayList();personList.add(new Person(Tom, 8900, 22, male, New Yark));personList.add(new Person(Jack, 7000, 29, male, Washington));personList.add(new Person(Lily, 7800, 24, female, Washington));personList.add(new Person(Anni, 8200, 28, female, New Yark));personList.add(new Person(Owen, 9500, 26, male, New Yark));personList.add(new Person(Alisa, 7900, 27, female, New Yark));Map?, Person personMap personList.stream().filter(p - p.getSalary() 8000).collect(Collectors.toMap(Person::getName,p - p));System.out.println(产生的新的map集合是 personMap); 3.统计(count/averaging) Collectors提供了一系列用于数据统计的静态方法 计数count 平均值averagingInt、averagingLong、averagingDouble 最值maxBy、minBy 求和summingInt、summingLong、summingDouble 统计以上所有summarizingInt、summarizingLong、summarizingDouble /*** 案例统计员工人数、平均工资、工资总额、最高工资。*/// 求总数Long count personList.stream().collect(Collectors.counting());System.out.println(员工总数 count);// 求平均工资Double avgSalary personList.stream().collect(Collectors.averagingDouble(Person::getSalary));System.out.println(员工平均工资 avgSalary);// 求工资之和Integer sumSalary personList.stream().collect(Collectors.summingInt(Person::getSalary));System.out.println(员工工资总和: sumSalary);// 一次性统计所有信息DoubleSummaryStatistics collect personList.stream().collect(Collectors.summarizingDouble(Person::getSalary));System.out.println(员工工资所有统计 collect); 分组(partitioningBy/groupingBy) 分区将stream按条件分为两个Map比如员工按薪资是否高于8000分为两部分。 分组将集合分为多个Map比如员工按性别分组。有单级分组和多级分组。 /*** 案例将员工按薪资是否高于8000分为两部分将员工按性别和地区分组*/// 将员工按薪资是否高于8000分组MapBoolean, ListPerson part personList.stream().collect(Collectors.partitioningBy(x - x.getSalary() 8000));// 将员工按性别分组MapString, ListPerson group personList.stream().collect(Collectors.groupingBy(Person::getSex));// 将员工先按性别分组再按地区分组MapString, MapString, ListPerson group2 personList.stream().collect(Collectors.groupingBy(Person::getSex,Collectors.groupingBy(Person::getArea)));System.out.println(员工按薪资是否大于8000分组情况 part);System.out.println(员工按性别分组情况 group);System.out.println(员工按性别、地区 group2); 接合(joining) joining可以将stream中的元素用特定的连接符没有的话则直接连接连接成一个字符串。 String names personList.stream().map(p - p.getName()).collect(Collectors.joining(,));System.out.println(所有员工的姓名 names);ListString strs Arrays.asList(A, B, C);String str strs.stream().collect(Collectors.joining(-));System.out.println(拼接后的字符串 str);归约(reducing) Collectors类提供的reducing方法相比于stream本身的reduce方法增加了对自定义归约的支持。 // 每个员工减去起征点后的薪资之和Integer sumsal personList.stream().collect(Collectors.reducing(0, Person::getSalary, (x, y) - x y - 5000));System.out.println(员工扣税薪资总和 sumsal);// stream的reduceInteger sum personList.stream().map(Person::getSalary).reduce(0, (x, y) - x y - 5000);System.out.println(----员工扣税薪资总和 sum);排序(sorted) sorted中间操作。有两种排序 sorted()自然排序流中元素需实现Comparable接口sorted(Comparator com)Comparator排序器自定义排序/*** 案例将员工按工资由高到低工资一样则按年龄由大到小排序*/ // 按工资升序排序自然排序 ListString nameList personList.stream().sorted(Comparator.comparing(Person::getSalary)).map(Person::getName).collect(Collectors.toList()); System.out.println(按工资升序排序自然排序: nameList); // 按工资降序排序 ListString nameList1 personList.stream().sorted(Comparator.comparing(Person::getSalary).reversed()).map(Person::getName).collect(Collectors.toList()); System.out.println(按工资降序排序: nameList1);// 先按工资再按年龄升序排序 ListString nameList2 personList.stream().sorted(Comparator.comparing(Person::getSalary).thenComparing(Person::getSalary)).map(Person::getName).collect(Collectors.toList()); System.out.println(先按工资再按年龄升序排序: nameList2);// 先按工资再按年龄自定义排序降序 ListString nameList3 personList.stream().sorted((p1, p2) - {if (p1.getSalary() p2.getSalary()) {return p2.getAge() - p1.getAge();} else {return p2.getSalary() - p1.getSalary();} }).map(Person::getName).collect(Collectors.toList()); System.out.println(先按工资再按年龄自定义排序降序: nameList3);提取/组合 流也可以进行合并(concat)、去重(distinct)、限制(limit)、跳过(skip)等操作。 String[] arr1 {a, b, c, d}; String[] arr2 {d, e, f, g};StreamString stream1 Stream.of(arr1); StreamString stream2 Stream.of(arr2);// concat:合并两个流 distinct去重 ListString stringList Stream.concat(stream1, stream2).distinct().collect(Collectors.toList()); System.out.println(流合并 stringList); // limit限制从流中获得前n个数据 ListInteger integerList Stream.iterate(1, x - x 2).limit(10).collect(Collectors.toList()); System.out.println(limit integerList); // skip跳过前n个数据 ListInteger integerList1 Stream.iterate(1, x - x 2).skip(1).limit(5).collect(Collectors.toList()); System.out.println(skip integerList1);
http://www.yutouwan.com/news/318359/

相关文章:

  • 襄樊seo快速排名seo引擎优化工具
  • 一个网站备案号是冒用其它公司的企业文化培训心得体会
  • 天津营销网站建设联系方式成都网站建设 平易云
  • 网站帮助中心设计邯郸招工信息网
  • 怎样在手机上制作网站visual studio
  • 网站双机热备怎么做西安市做网站公司有哪些
  • 网站没有icp备案怎么访问南昌装修公司
  • 网站建设 案例互联网装饰网站
  • 销售网站模板搭建视频服务器
  • 网站开发流程pptwordpress指定关键词自动内链
  • 珠宝企业的门户网站开发知乎自媒体平台注册
  • wamp在网站建设中的功能及协作关系深圳网站seo优化公司
  • 阿里云备案 网站备案域名购买什么网站从做系统
  • 营销型网站建设调查表如何做公司介绍视频网站
  • 如何备份网站网站做营销推广的公司
  • 商丘网站建设推广渠道企业网站建设的意义
  • 票务网站开发端口iis网站目录权限
  • 做灯饰的企业都会在哪些网站网站设计规划说明书
  • 网站推广哪个平台好中英文网站栏目修改
  • 海南网站优化公司广州市网络预约出租汽车综合业务管理平台
  • 新做的网站怎样让百度收录金华网站建设公司
  • 上海市网站建设公司58wordpress 猫
  • 自适应自助建站网站人才招聘网站建设
  • 外贸网站搜索引擎优化方法杭州网站建设app
  • 绍兴网页设计优化师是一份怎样的工作
  • 做网站源码需要多少钱泊头在哪做网站比较好
  • 搜狗网站做滤芯怎么样营销型企业网站功能
  • 江西网站建设与推广湛江网站建设外包
  • 做网站注意设么专业网站制作推荐
  • 湛江公司做网站景德镇陶瓷学院校友做网站的