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

如何做网站 写代码社区推广

如何做网站 写代码,社区推广,新乡公司做网站找哪家公司好,私企建筑公司排名背景 函数式接口很简单,但是不是每一个函数式接口都需要我们自己来写jdk 根据 有无参数,有无返回值,参数的个数和类型,返回值的类型 提前定义了一些通用的函数式接口 IntPredicate 参数:有一个,类型是int类…

背景

  • 函数式接口很简单,但是不是每一个函数式接口都需要我们自己来写
  • jdk 根据 有无参数,有无返回值,参数的个数和类型,返回值的类型 提前定义了一些通用的函数式接口

IntPredicate

  • 参数:有一个,类型是int类型
  • 返回值:返回值是boolean类型 所以是Predicate
    在这里插入图片描述
IntPredicate type1_1 = (int a) -> (a & 1) == 0;@FunctionalInterface
interface MyInterface1{boolean   op(int arg1);
}

IntBinaryOperator

  • 参数:两个int 所以是Binary
  • 返回值:和参数一样是int 所以是Operator
IntBinaryOperator type4_1 = (int a, int b) -> a + b;
IntBinaryOperator type5_1 = (int a, int b) -> a * b;@FunctionalInterface
interface MyInterface3{int op(int num1, int num2);
}

Supplier

  • 参数:无
  • 返回值:没有参数但是有返回值,所以是Supplier
 Supplier<Student> type6_2 = () -> new Student("张三", 18);Supplier<List<Student>> type7_2 = () -> {List<Student> list = new ArrayList<>();list.add(new Student("张三", 18));list.add(new Student("李四", 19));return list;};// MyInterface5和MyInterface4是可以使用泛型合并的
@FunctionalInterface
interface MyInterface5_1<T>{T op() ;
}

Function

  • 有参数,也有返回值
  • 但是参数类型和返回值类型不一样,所以是Function
Function<Student,String> type8_2 = (Student student) -> student.getName();
Function<Student,Integer> type9_2 = (Student student) -> student.getage();//MyInterface6和MyInterface7是可以使用泛型合并的
// O是返回值类型,I是入参类型
@FunctionalInterface
interface MyInterface8<I,O>{O op(I inObj) ;
}

常见的函数式接口

在这里插入图片描述

命名规则

在这里插入图片描述

练习

  • 获取list中的偶数数据
  • 返回的是Boolean类型的结果,使用进行Predicate接口接受
  public static void main(String[] args) {List<Integer> list = new ArrayList<>();for (int i = 0; i < 10; i++) {list.add(i);}// 获取偶数List<Integer> evenNumbers = filter(list, i -> i % 2 == 0);System.out.println(evenNumbers);}// 传递两个参数:一个列表和一个 Predicate 接口,对列表进行过滤static List<Integer> filter(List<Integer> list, Predicate<Integer> predicate) {List<Integer> result = new ArrayList<>();for (Integer i : list) {// 使用 Predicate 的 test() 方法判断元素是否满足条件 if (predicate.test(i)) {result.add(i);}}return result;}
http://www.tj-hxxt.cn/news/21109.html

相关文章:

  • 广州做网站要多少钱站长推荐
  • 广州网站建设 美词网络营销策略论文
  • 央视叫停校外培训机构重庆seo网络优化师
  • 做新媒体国外网站青岛百度快速排名优化
  • 服装网购哪个平台最好seo综合查询是什么
  • 怎么做网站的今天的新闻主要内容
  • 上海公司做网站汕头seo代理商
  • 辽宁省建设厅证书查询网站网站维护工程师
  • 做设计什么网站平台好点做私活码迷seo
  • 专做视频和ppt的网站百度app官方下载安装到手机
  • 福建省网站建设seo优化专家
  • 新网站如何做排名佛山seo培训
  • 沈阳专业网站建设百度提交网站收录入口
  • 涟水网站建设游戏推广员如何推广引流
  • 在哪个网站做推广好搭建网站的五大步骤
  • 做网站为什么能赚钱互联网营销推广
  • 网站开发项目章程示例百度在线问答
  • 做直播网站用什么语言万网是什么网站
  • 河北省唐山市建设规划局的网站磁力宅在线搜种子
  • 用阿里云做网站庆云网站seo
  • 花生壳怎么建设网站cms系统
  • 欢迎访问中国建设银行网站个人客户淮北网站建设
  • 辽宁建设工程信息网登录入口河南网站推广优化排名
  • 网站分为太原网站建设开发
  • 广州网站推广¥做下拉去118cr网址安全中心检测
  • 购物网站首页模板下载seo81
  • 网站开发交接资料站长工具在线
  • 网站上线确认书网络营销公司名字
  • 网站充值这么做seo教程
  • 网站版面设计网站推广排名公司