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

地方门户网站建设方案企业网站建设合同 百度文库

地方门户网站建设方案,企业网站建设合同 百度文库,系统模板html,安卓优化大师官网下载1、anyMatch 判断数据列表中是否存在任意一个元素符合设置的predicate条件#xff0c;如果是就返回true#xff0c;否则返回false。 接口定义#xff1a; boolean anyMatch(Predicate? super T predicate); 方法描述#xff1a; 在anyMatch 接口定义中是接收 P…1、anyMatch  判断数据列表中是否存在任意一个元素符合设置的predicate条件如果是就返回true否则返回false。 接口定义 boolean anyMatch(Predicate? super T predicate); 方法描述 在anyMatch 接口定义中是接收 Predicate 类型参数在Lamdba表达式中 PredicateT 是接收一个T类型参数然后经过逻辑验证返回布尔值结果。这里anyMatch表示判断的条件里任意一个元素符合条件就返回true值。 使用场景 两个集合的交集   Testpublic void a17() {ListUser list new ArrayList();list.add(new User(张三, 12, 南京));list.add(new User(李四, 13, 北京));list.add(new User(王五, 14, 苏州));list.add(new User(王五, 17, 苏州));ListUser userList new ArrayList();userList.add(new User(李四, 13, 北京));userList.add(new User(王五, 20, 广州));// 获取两个集合中有相同名字或者年龄相同的只要满足其中一个条件即可只会返回list集合里面的元素有先后顺序返回ListUser users1 list.stream().filter(a - userList.stream().anyMatch(b - a.getName().equals(b.getName()) || a.getAge() b.getAge())).collect(Collectors.toList());// 获取两个集合中相同名字并且年龄相同的必须同时满足两个条件ListUser users2 list.stream().filter(a - userList.stream().anyMatch(b - a.getName().equals(b.getName()) a.getAge() b.getAge())).collect(Collectors.toList());users1.forEach(item - {System.out.println(item.getName() item.getAge() item.getEmailAddress());});/** 第一种结果展示* 李四13北京* 王五14苏州* 王五17苏州*/users2.forEach(item - {System.out.println(item.getName() item.getAge() item.getEmailAddress());});/** 第二种结果展示* 李四13北京*/}Test public void a15() {StreamString stream Stream.of(ac, bcddddd, bd);// 判断stream中其中任何一个元素中只要有包含b字符串或者l字符串就返回trueboolean isMatch stream.anyMatch(str - str.contains(b) || str.contains(l));System.out.println(isMatch); // true } 2、allMatch 判断数据列表中全部元素都符合设置的predicate条件如果是就返回true否则返回false流为空时总是返回true。 接口定义 boolean allMatch(Predicate? super T predicate); 方法描述 在allMatch 接口定义中是接收 Predicate 类型参数在Lamdba表达式中 PredicateT 是接收一个T类型参数然后经过逻辑验证返回布尔值结果。这里allMatch表示判断的条件里全部元素符合条件就返回true值。 适用场景 基本类型的集合但不适合于对象集合我自己的理解 allMatch里面不适合写 只适合写 ||如果写编译器会自动报黄色波浪线   Test public void a18() {ListString typeList1 Arrays.asList(1, 2);ListString typeList2 Arrays.asList(1, 2, 3, 4);// 集合列表中全部元素必须在allMatch里面的那些字符串只要全部元素中有任意一个不同的元素在AllMatch中就返回falseboolean isMatch1 typeList1.stream().allMatch(a - a.equals(1) || a.equals(2) || a.equals(3));boolean isMatch2 typeList2.stream().allMatch(a - a.equals(1) || a.equals(2) || a.equals(3));System.out.println(isMatch1); // trueSystem.out.println(isMatch2); // false }Test public void a16() {StreamString stream Stream.of(abc, abc, bcd);// 判断stream中全部所有元素必须全部包含b字符串和c字符串就返回true如果有一个元素不包含这两个字符串就返回falseboolean isMatch stream.allMatch(str - str.contains(b) str.contains(c));System.out.println(isMatch); // true } 3、noneMatch 判断数据列表中全部元素都不符合设置的predicate条件如果是就返回true否则返回false流为空时总是返回true。 接口定义 boolean noneMatch(Predicate? super T predicate); 方法描述 在noneMatch接口定义中是接收 Predicate 类型参数在Lamdba表达式中 PredicateT 是接收一个T类型参数然后经过逻辑验证返回布尔值结果。这里noneMatch表示与allMatch相反判断的条件里的元素所有的元素都不符合就返回true值。 适用场景 两个集合的差集 本人只想到这么做如果有更简洁的可以告诉我怎么写感谢0.0   Test public void a17() {ListUser list new ArrayList();list.add(new User(张三, 12, 南京));list.add(new User(李四, 13, 北京));list.add(new User(王五, 14, 苏州));list.add(new User(王五, 17, 苏州));ListUser userList new ArrayList();userList.add(new User(李四, 13, 北京));userList.add(new User(王五, 20, 广州));// 获取list集合和userList集合过滤掉两者集合中名字和年龄相同的数据后只返回list集合的数据ListUser users3 list.stream().filter(a - userList.stream().noneMatch(b - a.getName().equals(b.getName()) a.getAge() b.getAge())).collect(Collectors.toList());// 获取userlist集合和list集合过滤掉两者集合中名字和年龄相同的数据后只返回userList集合的数据ListUser users4 userList.stream().filter(a - list.stream().noneMatch(b - a.getName().equals(b.getName()) a.getAge()b.getAge())).collect(Collectors.toList());// 获取list和userList集合之间的差集将上面两者集合合并就是两个集合的差集ListUser arrayList new ArrayList();arrayList.addAll(users3);arrayList.addAll(users4);arrayList.forEach(item - {System.out.println(item.getName() item.getAge() item.getEmailAddress());});/** 两者集合之间的差集* 张三12南京* 王五14苏州* 王五17苏州* 王五20广州*/System.out.println(-------------------);users3.forEach(item - {System.out.println(item.getName() item.getAge() item.getEmailAddress());});/** 只返回list集合中过滤掉之后的元素集合* 张三12南京* 王五14苏州* 王五17苏州*/System.out.println(-------------------);users4.forEach(item - {System.out.println(item.getName() item.getAge() item.getEmailAddress());});/** 只返回userList集合中过滤掉之后的元素集合* 王五20广州*/ }Test public void a19() {ListString typeList1 Arrays.asList(1, 2);ListString typeList2 Arrays.asList(1, 2, 3, 4);// 集合列表中全部元素只要都不在noneMatch里面的判断中就返回true集合列表中任何元素中只要有一个在noneMatch的判断中就返回falseboolean isMatch1 typeList1.stream().noneMatch(a - a.equals(3) || a.equals(4));boolean isMatch2 typeList2.stream().noneMatch(a - a.equals(1) || a.equals(2) || a.equals(3));System.out.println(isMatch1); // trueSystem.out.println(isMatch2); // false }/** noneMatch */ Test public void a20() {StreamString stream Stream.of(dddd, ee, qqq, bcfff);// 判断 stream 中所有的元素都不是以 a 开头就返回true如果所有的元素中只要其中一个元素是以a开头的就返回falseboolean isMatch stream.noneMatch(str-str.startsWith(a));System.out.println(isMatch); // true }
http://www.sadfv.cn/news/387788/

相关文章:

  • 南宁企业网站排名优化wordpress 301 插件
  • o2o网站建设最好公司排名网站微信建设方案
  • 石家庄微网站哪个网站上可以做初中数学题
  • 睿艺美开封做网站我想注册一个做门窗的网站应该怎样做
  • 网站开发市场 知乎基地网站建设方案
  • 网站运营外包公司网站建设要用多少种字体
  • 石家庄网站建设优化如何做好网站宣传
  • 怎么在网站后面做链接软件制作思维导图的优势
  • 网站建设公司的网销好做吗品牌网首页
  • wordpress建2个网站腾讯云wordpress搭建网站
  • 网站架设流程工厂源头货源app
  • 模板之家网站百度app下载最新版
  • 盐城滨海建设局网站开户推广竞价开户
  • 销售网站怎么做的广州网站公司
  • 番禺做网站最便宜的哪家公司郴州网站建设系统
  • 做网站需要什么编程语言海外推广电商
  • 星空传媒有限公司网站做汉字的教育网站
  • 电子商务网站开发背景意义建网站推广效果怎么样
  • 信阳住房和城乡建设局网站扬州哪里做网站
  • 做企业网站要用什么软件网站开发承诺函
  • 一般做网站带宽选择多大的网站开发技术路线
  • 太仓建设局网站乐清建设网站公司
  • 合肥网页设计工资一般多少seo优化厂家
  • 动易网站 首页模板修改百度收录网站之后又怎么做
  • 铁路网站建设wordpress页面文本
  • 深圳移动网站建设微信小程序游戏制作平台
  • 深圳建设网站公司哪儿济南兴田德润有活动吗更改wordpress登陆页面logo
  • 网站建设 微信开发虫部落导航网站怎么做
  • asp网站开发教程pdf绵阳网站搜索优化
  • 个人网站后期怎么做企业企业网址怎么注册