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

网站建设维护要加班吗大连在哪儿

网站建设维护要加班吗,大连在哪儿,画廊网站建设,给上市公司做网站有什么用我一直落后于Java 8所关注的功能#xff0c;因此在这篇文章中#xff0c;我将简要介绍我对lambda和stream的初步经验。 和往常一样#xff0c;我将专注于Podcast课程#xff1a; package org.codingpedia.learning.java.core;import java.util.Comparator;public class P… 我一直落后于Java 8所关注的功能因此在这篇文章中我将简要介绍我对lambda和stream的初步经验。 和往常一样我将专注于Podcast课程 package org.codingpedia.learning.java.core;import java.util.Comparator;public class Podcast {int id;String title;String producer;int subscriptionsNumber;/** number of up votes(likes) */int upVotes;/** number of down votes*/int downVotes;public Podcast() {this.subscriptionsNumber 0;}public Podcast(int id, String title, String producer, int subscriptionsNumber, int upVotes, int downVotes) {this.id id;this.title title;this.producer producer;this.subscriptionsNumber subscriptionsNumber;this.upVotes upVotes;this.downVotes downVotes;}public static final ComparatorPodcast BY_POSITIVE_VOTES_DIFFERENCE (left, right) - (right.getUpVotes()-right.getDownVotes()) - (left.getUpVotes()-left.getDownVotes());Overridepublic String toString() {return Podcast{ title title \ , producer producer \ , upVotes upVotes , downVotes downVotes , subscriptionsNumber subscriptionsNumber };}public static String toJSON(Podcast p) {return { title: p.title \ , producer: p.producer \ , upVotes: p.upVotes , downVotes: p.downVotes , subscriptionsNumber: p.subscriptionsNumber };}public int getUpVotes() {return upVotes;}public void setUpVotes(int upVotes) {this.upVotes upVotes;}public int getDownVotes() {return downVotes;}public void setDownVotes(int downVotes) {this.downVotes downVotes;}public String getTitle() {return title;}public void setTitle(String title) {this.title title;}public String getProducer() {return producer;}public void setProducer(String producer) {this.producer producer;}public int getSubscriptionsNumber() {return subscriptionsNumber;}public void setSubscriptionsNumber(int subscriptionsNumber) {this.subscriptionsNumber subscriptionsNumber;}public int getId() {return id;}public void setId(int id) {this.id id;} } 我将在用lambda和流构建的不同操作中使用。 但是我这次让代码说明一切 Lambda和流示例 package org.codingpedia.learning.java.core;import java.util.*; import java.util.function.Predicate; import java.util.stream.Collectors;public class LambdasAndStreams {public static void main(String[] args) {ListPodcast podcasts Arrays.asList(//new Podcast(podcastId, title, producer, subscriptionsNumber, upVotes, downVotes),new Podcast(1, QuarksCo, wdr, 50, 18, 1),new Podcast(2, Angeklickt - zum Mitnehmen, wdr, 10, 5, 1),new Podcast(3, Leonardo im WDR 5-Radio zum Mitnehmen, wdr, 12, 10, 5),new Podcast(4, LESPRIT PUBLIC, France culture, 3, 10, 1),new Podcast(5, LA FABRIQUE DE LHISTOIRE, France culture, 10, 4, 1),new Podcast(6, LES MATINS DE FRANCE CULTURE, France culture, 46, 12, 8));System.out.println(*********** Display initial podcasts with forEach ************);podcasts.forEach(podcast - System.out.println(podcast));System.out.println(\n\n********************** Sorting with lambdas ***********************);// Sort by titleSystem.out.println(\n*********** Sort by title (default alphabetically) - highlight comparator ************);Collections.sort(podcasts, Comparator.comparing(Podcast::getTitle));podcasts.forEach(podcast - System.out.println(podcast));System.out.println(\n*********** Sort by numbers of subscribers DESCENDING - highlight reversed ************);Collections.sort(podcasts, Comparator.comparing(Podcast::getSubscriptionsNumber).reversed());podcasts.forEach(podcast - System.out.println(podcast));System.out.println(\n*********** Sort by producer and then by title - highlight composed conditions************);Collections.sort(podcasts, Comparator.comparing(Podcast::getProducer).thenComparing(Podcast::getTitle));podcasts.forEach(podcast - System.out.println(podcast));System.out.println(\n*********** Sort by difference in positive votes DESCENDING ************);Collections.sort(podcasts, Podcast.BY_POSITIVE_VOTES_DIFFERENCE);podcasts.forEach(podcast - System.out.println(podcast));System.out.println(\n\n******************** Streams *************************);System.out.println(\n*********** Filter podcasts with more than 21 subscribers - highlight filters ************);podcasts.stream().filter((podcast)- podcast.getSubscriptionsNumber() 21).forEach((podcast)-System.out.println(podcast));System.out.println(\n********* Filter podcasts from producer with more than 21 subscribers - highlight predicate **************);PredicatePodcast hasManySubscribers (podcast) - podcast.getSubscriptionsNumber() 21;PredicatePodcast wdrProducer (podcast) - podcast.getProducer().equals(wdr);podcasts.stream().filter(hasManySubscribers.and(wdrProducer)).forEach((podcast) -System.out.println(podcast));System.out.println(\n********* Display popular podcasts - highlight \or\ in predicate **************);PredicatePodcast hasManyLikes (podcast) - (podcast.getUpVotes()-podcast.getDownVotes()) 8;podcasts.stream().filter(hasManySubscribers.or(hasManyLikes)).forEach((podcast) -System.out.println(podcast));System.out.println(\n********* Collect subscription numbers - highlight \mapToInt\ **************);int numberOfSubscriptions podcasts.stream().mapToInt(Podcast::getSubscriptionsNumber).sum();System.out.println(Number of all subscriptions : numberOfSubscriptions);System.out.println(\n********* Display podcast with most subscriptions -highlight \map reduce\ capabilities **************);Podcast podcastWithMostSubscriptions;podcastWithMostSubscriptions podcasts.stream().map(podcast - new Podcast(podcast.getId(), podcast.getTitle(), podcast.getProducer(), podcast.getSubscriptionsNumber(), podcast.getUpVotes(), podcast.getDownVotes())).reduce(new Podcast(),(pod1, pod2) - (pod1.getSubscriptionsNumber() pod2.getSubscriptionsNumber()) ? pod1 : pod2);System.out.println(podcastWithMostSubscriptions);System.out.println(\n********* Display podcasts titles in XML format -highlight \map reduce\ capabilities **************);String titlesInXml podcasts datatitles podcasts.stream().map(podcast - title podcast.getTitle() /title).reduce(, String::concat) /podcasts;System.out.println(titlesInXml);System.out.println(\n********* Display podcasts in JSON format -highlight \map reduce\ capabilities **************);String json podcasts.stream().map(Podcast::toJSON).reduce([, (l, r) - l (l.equals([) ? : ,) r) ];System.out.println(json);System.out.println(\n********* Display sorted podcasts by title in JSON format -highlight \map collect\ capabilities **************);String jsonViaCollectors podcasts.stream().sorted(Comparator.comparing(Podcast::getTitle)).map(Podcast::toJSON).collect(Collectors.joining(,, [, ]));System.out.println(jsonViaCollectors);System.out.println(\n********* Select first 3 podcasts with most subscribers -highlight \map collect\ capabilities **************);ListPodcast podcastsWithMostSubscribers podcasts.stream().sorted(Comparator.comparing(Podcast::getSubscriptionsNumber).reversed()).limit(3).collect(Collectors.toList());System.out.println(podcastsWithMostSubscribers);System.out.println(\n********* Get podcasts grouped by producer -highlight \collector\ capabilities **************);MapString, ListPodcast podcastsByProducer podcasts.stream().collect(Collectors.groupingBy(podcast - podcast.getProducer()));System.out.println(podcastsByProducer);} }资源资源 Java 8中央 Java 8Lambdas第1部分 Java 8Lambdas第2部分 翻译自: https://www.javacodegeeks.com/2015/03/yet-another-java-8-lamdbas-and-streams-example.html
http://www.zqtcl.cn/news/580675/

相关文章:

  • 深圳市设计网站公司自己做网站开网店
  • 智能建站cms管理系统修改wordpress时区
  • 站长怎么添加网站内容重庆网站推
  • 东莞网站建设属于什么专业网页设计代码书
  • 网站后台代码在哪修改wordpress添加搜索小工具
  • 爱站站长工具中国建设监理协会官方网站
  • 珠海微信网站开发东莞网站制作方案定制
  • 大学网站建设说明书记的网站域名
  • 网站如何开通支付功能第一ppt课件免费下载官网
  • 做1元夺宝网站挣钱吗美工网站设计收费
  • 华侨城网站开发wordpress页码颜色
  • 上海建站网络公司制作文字图片
  • 平台型网站制作网站建设张世勇
  • 网站建设云南网页游戏大厅都有哪些
  • 网站建设与管理报告书郑州建设银行网站
  • 做网站网页的人是不是思维公司网站建设包括
  • 网站建设都包括哪些网站后台如何上传文件
  • 网站便民服务平台怎么做迁安做网站中的cms开发
  • 做外贸比较好的网站怎么把网站做的好看
  • 有没有在淘宝找人做网站被骗过的台州市环保局网站开发区
  • 公司外文网站制作河南住房和城乡建设厅网站
  • 东莞做网站公司有哪些代码网站推荐
  • 棋类游戏网站开发网站首页顶部图片尺寸
  • 工信部如何查网站备案大连网络推广广告代理
  • 网站建设基本流程心得wordpress首页截断
  • 网站包括哪些内容网站开发的相关技能
  • 百度竞价 百度流量 网站权重qq推广
  • 重庆网站建设总结WordPress简单百度站长插件
  • pc网站转换成微网站工作室推广网站
  • 嘉兴优化网站公司做水果生意去哪个网站