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

做彩票网站服务器网页制作基础题

做彩票网站服务器,网页制作基础题,怎么做域名网站备案,wordpress怎么弄在线表单java.util接口在上一篇文章中#xff0c;我写了关于Function接口的内容 #xff0c;它是java.util.package的一部分。 我还提到了Predicate接口#xff0c;它是同一包的一部分#xff0c;在这篇文章中#xff0c;我将向您展示如何使用Predicate和Consumer接口。 让我们看一… java.util接口 在上一篇文章中我写了关于Function接口的内容 它是java.util.package的一部分。 我还提到了Predicate接口它是同一包的一部分在这篇文章中我将向您展示如何使用Predicate和Consumer接口。 让我们看一下Javadoc for Predicate接口 确定输入对象是否符合某些条件。 并且在该接口中声明/定义了5种方法您一定想知道这是一个功能性接口 如果是则必须在继续之前阅读此方法这些方法是 //Returns a predicate which evaluates to true only if this predicate //and the provided predicate both evaluate to true. and(Predicate? super T p)//Returns a predicate which negates the result of this predicate. negate()//Returns a predicate which evaluates to true if either //this predicate or the provided predicate evaluates to true or(Predicate? super T p)//Returns true if the input object matches some criteria test(T t)//Returns a predicate that evaluates to true if both or neither //of the component predicates evaluate to true xor(Predicate? super T p) 除testT t以外的所有方法均为默认方法而testT t为抽象方法。 提供此抽象方法实现的一种方法是使用匿名内部类另一种方法是使用lambda表达式 。 用于消费者接口的Javadoc指出 接受单个输入参数且不返回结果的操作。 与大多数其他功能接口不同消费者应该通过副作用进行操作。 此接口中有2种方法其中只有一种是抽象的而该抽象方法是acceptT t它接受输入并且不返回任何结果。 要解释有关谓词和消费者界面的更多信息我们考虑一个带有名称等级和要支付费用的学生班。 每个学生都有一定的折扣折扣取决于学生的成绩。 class Student{String firstName;String lastName;Double grade;Double feeDiscount 0.0;Double baseFee 20000.0;public Student(String firstName, String lastName,Double grade) {this.firstName firstName;this.lastName lastName;this.grade grade;}public void printFee(){Double newFee baseFee - ((baseFee*feeDiscount)/100);System.out.println(The fee after discount: newFee);} } 并让我们创建一个接受Student对象谓词实现和Consumer实现的方法。 如果您不熟悉Function接口那么您应该花几分钟阅读本文档。 此方法使用谓词来确定是否必须更新学生对费用的折扣然后使用Consumer实现来更新折扣。 public class PreidcateConsumerDemo {public static Student updateStudentFee(Student student,PredicateStudent predicate,ConsumerStudent consumer){//Use the predicate to decide when to update the discount.if ( predicate.test(student)){//Use the consumer to update the discount value.consumer.accept(student);}return student;}} 谓词和使用者中的测试方法和接受方法都分别接受声明的泛型类型的参数。 两者之间的区别在于谓词使用参数来做出决定并返回布尔值而消费者使用参数来改变其某些值。 让我们看一下如何调用updateStudentFee方法 public static void main(String[] args) {Student student1 new Student(Ashok,Kumar, 9.5);student1 updateStudentFee(student1,//Lambda expression for Predicate interfacestudent - student.grade 8.5,//Lambda expression for Consumer inerfacestudent - student.feeDiscount 30.0);student1.printFee();Student student2 new Student(Rajat,Verma, 8.0);student2 updateStudentFee(student2,student - student.grade 8,student - student.feeDiscount 20.0);student2.printFee();} 在这篇文章中我通过示例解释了如何利用Predicate和Consumer接口它们是Java 8中引入的java.util.function包的一部分。 参考来自JCG合作伙伴 Mohamed Sanaulla的Java 8中java.util.function包中的谓词和使用者接口来自Experiences Unlimited博客。 翻译自: https://www.javacodegeeks.com/2013/04/predicate-and-consumer-interface-in-java-util-function-package-in-java-8.htmljava.util接口
http://www.sadfv.cn/news/125010/

相关文章:

  • 网站架构制作夏都西宁吧
  • 网站开发报价和开发周期网站建设手机端页面模板
  • 泽库县公司网站建设网站模版可以套用吗
  • 梦幻西游网页版官方网站做衣服的网站推荐
  • 汉唐皓月网站推广方案成都网站建设成都app开发
  • 贵阳网站建设需要多少钱免费推广平台有哪些?
  • 网站视频下载方法做会员卡网站
  • 网站建设投标书免费国内免费商用图片的网站
  • 临湘做网站滦平县建设局网站
  • 公司网站建设都需要什么内容给人做ppt的网站吗
  • 南京网站流量优化seo运营
  • 学校门户网站群建设方案如何做后台网站的教程
  • 广州建设网站技术徐州网站快速优化排名
  • 做网站前端有前途么?网店代运营
  • 定南网站建设国外建设网站情况报告
  • 网站怎么进自己的代码放WordPress
  • 局网站建设iis7配置网站404页面
  • 孝感市建设局网站阳朔到桂林
  • 石家庄做商城网站的公司wordpress模板分享
  • 简单的网站架构wordpress+大附件
  • 网站静态页面下载工具wordpress邮箱登录
  • 网站建设积分番禺核酸检测点在哪
  • 合肥php网站开发html5教程视频教程
  • h5免费制作网站模板青岛做网站建设的公司
  • 电影网站建设教学视频大连建设工程信息网(官网)
  • 建站排名新手如何做企业网站
  • dj音乐网站建设怎么注册公司名字和商标
  • 网站开发要写代码吗广州天河区网站设计公司
  • 最专业的手机网站建设网页搜索引擎
  • 上海好的高端网站建设wordpress php占内存