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

广元如何做百度的网站seo网站推广优化

广元如何做百度的网站,seo网站推广优化,烟台网站制作设计,wordpress 网店模板制作目录 1. 什么是函数式接口 函数式接口 示例 示例 2. 函数式编程 示例 3. Lambda 表达式延迟执行 应用场景 示例 4. Consumer 接口 解释说明 示例 5. BiConsumer 接口 解释说明 示例 6. Predicate 接口 解释说明 示例 练习 7. Function 接口 解释说明 示例…目录 1. 什么是函数式接口 函数式接口 示例 示例 2. 函数式编程 示例 3. Lambda 表达式延迟执行 应用场景 示例 4. Consumer 接口 解释说明 示例 5. BiConsumer 接口 解释说明 示例 6. Predicate 接口 解释说明 示例 练习 7. Function 接口 解释说明 示例 练习 1. 什么是函数式接口 函数式接口 A functional interface is any interface that contains only one abstract method. (A functional interface may contain one or more default methods or static methods.) Because a functional interface contains only one abstract method, you can omit the name of that method when you implement it.         函数式接口是仅包含一种抽象方法的任何接口。 一个函数式接口可能包含一个或多个默认方法或静态方法。由于一个函数式接口仅包含一个抽象方法因此在实现该方法时可以省略该方法的名称。 示例 public interface Hello {         void sayHello ( String name );         static void show (){}         default void print (){}         private void test (){} } JDK8 专门为函数式接口提供了一个注解标识 FunctionalInterface 该注解只能使用在接口类型的定义上表明这是一个函数式接口 编译器在编译时就是会对该接口进行检测接口中是否只有一个抽 象接口方法。如果有多个抽象接口方法或者一个抽象接口方法也没有则将报编译错误 示例 FunctionalInterface public interface Hello {         void sayHello ( String name );         static void show (){}         default void print (){}         private void test (){} } 注意 如果接口类型上没有 FunctionalInterface 注解但接口中只有一个抽象方法这个接口也 是函数式接口。这与 Override 注解一样即使方法上面没有写同样是属于方法重写 2. 函数式编程         函数式编程是一种编程方式在 Java 中简单来说就是一个变量能够存储一个函数。而能够实现这种赋值操作的只有 Lambda 表达式 示例 FunctionalInterface public interface Hello {         void sayHello ( String name );         static void show (){}         default void print (){}         // private void test(){} } package com . wq . functional ; public class HelloTest {         public static void main ( String [] args ) {                 // Hello hello name - System.out.println(name);                 Hello hello System . out :: println ;                 hello . sayHello ( Marry );         } } 3. Lambda 表达式延迟执行 应用场景         在某种条件下才会处理数据 示例 package com . wq . lambda . lazy ; public interface MsgBuilder {         String buildMsg ( String ... infos ); } package com . wq . lambda . lazy ; public class PrintUtil {         public static void print ( boolean valid , String msg ){                 if ( valid ){                         System . out . println ( msg );                 }         }         private static String build ( String ... infos ){                 StringBuilder builder new StringBuilder ();                 for ( String info : infos ){                         builder . append ( info );                 }                 return builder . toString ();         }         public static void print ( boolean valid , String ... infos ){                 if ( valid ){                         // MsgBuilder builder new MsgBuilder() {                                 // Override                                 // public String buildMsg(String... infos) {                                         // return PrintUtil.build(infos);                                 // }                         // };                         // MsgBuilder builder (String... arr) - {                                 // return PrintUtil.build(arr);                         // };                         // MsgBuilder builder arr - PrintUtil.build(arr);                         MsgBuilder builder PrintUtil :: build ;                         System . out . println ( builder . buildMsg ( infos ));                 }         } } package com . wq . lambda . lazy ; public class PrintTest {         public static void main ( String [] args ) {                 String name Marry ;                 String desc is friendly ;                 //不会打印任何信息但是此时已经完成了字符串的组装这是属于性能上的浪费                 PrintUtil . print ( false , name desc );                 //不会打印任何信息但是也未构建字符串                 PrintUtil . print ( false , name , desc );                 //会打印信息时才会构建字符串                 PrintUtil . print ( true , name , desc );         } } 4. Consumer 接口 void accept ( T t ); // 接收一个被消费的数据 解释说明         Consumer 顾名思义就是消费者的意思。可以消费一个被接收到的数据至于如何消费就需要看这个接口被如何实现。 示例 package com . wq . consumer ; import java . util . Arrays ; import java . util . HashSet ; import java . util . List ; import java . util . Set ; import java . util . function . Consumer ; public class ConsumerTest {         public static void main ( String [] args ) {                 // ConsumerString c1 new ConsumerString() {                         // Override                         // public void accept(String s) {                                 // System.out.println(s);                         // }                 // };                 // ConsumerString c1 (String s) - {                         // System.out.println(s);                 // };                 // ConsumerString c1 s - System.out.println(s);                 Consumer String c1 System . out :: println ;                 c1 . accept ( 这是被消费的信息 );                 // ConsumerString c2 new ConsumerString() {                         // Override                         // public void accept(String s) {                                 // System.out.println(s.charAt(0));                         // }                 // };                 Consumer String c2 s - System . out . println ( s . charAt ( 0 ));                 c2 . accept ( This is a consumer );                 Consumer String c3 c1 . andThen ( c2 );                 c3 . accept ( 先打印再取第一个字符 );                 //将数组转换为集合                 List Integer numbers Arrays . asList ( 1 , 2 , 3 , 4 , 5 );                 // numbers.forEach(new ConsumerInteger() {                         // Override                         // public void accept(Integer integer) {                                 // System.out.println(integer);                         // }                 // });                 //                 // numbers.forEach(integer - System.out.println(integer));                 numbers . forEach ( System . out :: println );                 Set String names new HashSet ();                 names . add ( admin );                 names . add ( test );                 names . add ( developer );                 // names.forEach(new ConsumerString() {                         // Override                         // public void accept(String s) {                                 // System.out.println(s);                         // }                 // });                 names . forEach ( System . out :: println );         } } 5. BiConsumer 接口 void accept ( T t , U u ); // 接收两个被消费的数据 解释说明         BiConsumer 也是一个消费者只是这个消费者可以一次性消费两个数据一般是键值对。至于如何消费就需要看这个接口被如何实现。 示例 package com . wq . consumer ; import java . util . HashMap ; import java . util . Map ; import java . util . function . BiConsumer ; public class BiConsumerTest {         public static void main ( String [] args ) {                 // BiConsumerString,Integer bc new BiConsumerString, Integer() {                         // Override                         // public void accept(String s, Integer integer) {                                 // System.out.println(s integer);                         // }                 // };                 BiConsumer String , Integer bc ( s , i ) - System . out . println ( s i );                 bc . accept ( a , 1 );                 Map String , String counties new HashMap ();                 counties . put ( CN , 中国 );                 counties . put ( EN , 英国 );                 counties . put ( US , 美国 );                 // counties.forEach(new BiConsumerString, String() {                         // Override                         // public void accept(String s1, String s2) {                                 // System.out.println(s1 s2);                         // }                 // });         counties . forEach (( s1 , s2 ) - System . out . println ( s1 s2 ));         } } 6. Predicate 接口 boolean test ( T t ); // 检测是否满足条件 default Predicate T and ( Predicate ? super T other ); // 条件之间的逻辑与衔接 default Predicate T negate (); // 条件取反 default Predicate T or ( Predicate ? super T other ); // 条件之间的逻辑或衔接 解释说明         Predicate 是条件的意思可以检测给定数据是否满足条件也可以与其他条件进行衔接。至于如何检测就需要看这个接口被如何实现。 示例 import java . util . function . Predicate ; public class PredicateTest {         public static void main ( String [] args ) {                 // PredicateString p1 new PredicateString() {                         // Override                         // public boolean test(String s) {                                 // return s.contains(中国);                         // }                 // };                 Predicate String p1 s - s . contains ( 中 );                 boolean result1 p1 . test ( 中华人民共和国 );                 System . out . println ( result1 );                 Predicate String p2 s - s . indexOf ( 啊 ) 0 ;                 boolean result2 p2 . test ( 中华人民共和国 );                 System . out . println ( result2 );                 Predicate String p3 p1 . negate (); // 取反                 System . out . println ( p3 . test ( 中华人民共和国 ));                 Predicate String p4 p1 . and ( p2 ); // 逻辑与衔接                 System . out . println ( p4 . test ( 中华人民共和国 ));                 Predicate String p5 p1 . or ( p2 ); // 逻辑或衔接                 System . out . println ( p5 . test ( 中华人民共和国 ));         } } 练习         学生有姓名、性别和年龄。现有一个集合内存储有10 名学生信息请找出其中性别为男年龄在 20 岁以上的学生并在控制台进行输出 package com . wq . predicate ; public class Student {         private String name ;         private String sex ;         private int age ;         public Student ( String name , String sex , int age ) {                 this . name name ;                 this . sex sex ;                 this . age age ;         }         public String getName () {                 return name ;         }         public void setName ( String name ) {                 this . name name ;         }         public String getSex () {                 return sex ;         }         public void setSex ( String sex ) {                 this . sex sex ;         }         public int getAge () {                 return age ;         }         public void setAge ( int age ) {                 this . age age ;         }         Override         public String toString () {                 return Student{                         name name \                         , sex sex \                         , age age                         } ;         } } package com . wq . predicate ; import java . util . Arrays ; import java . util . List ; import java . util . function . Consumer ; import java . util . function . Predicate ; public class Exercise {         public static void main ( String [] args ) {                 List Integer numbers Arrays . asList ( 1 , 2 , 3 , 4 , 5 );                 List Student students Arrays . asList (                         new Student ( 管理员 1 , 男 , 20 ),                         new Student ( 管理员 2 , 女 , 21 ),                         new Student ( 管理员 3 , 男 , 22 ),                         new Student ( 管理员 4 , 女 , 23 ),                         new Student ( 管理员 5 , 男 , 24 ),                         new Student ( 管理员 6 , 女 , 18 ),                         new Student ( 管理员 7 , 男 , 16 ),                         new Student ( 管理员 8 , 女 , 19 ),                         new Student ( 管理员 9 , 男 , 20 ),                         new Student ( 管理员 0 , 女 , 23 )                 );                 // PredicateStudent p1 new PredicateStudent() {                         // Override                         // public boolean test(Student student) {                                 // return 男.equals(student.getSex());                         // }                 // };                 Predicate Student p1 stu - 男 . equals ( stu . getSex ());                 Predicate Student p2 stu - stu . getAge () 20 ;                 Predicate Student p3 p1 . and ( p2 );                 // students.forEach(new ConsumerStudent() {                         // Override                         // public void accept(Student student) {                                 // if(p3.test(student)){                                         // System.out.println(student);                                 // }                         // }                 // });                 students . forEach ( student - {                         if ( p3 . test ( student )){                                 System . out . println ( student );                         }                 });         } } 7. Function 接口 R apply ( T t ); // 将一个对象转换为另一种数据类型的对象 default V Function T , V andThen ( Function ? super R , ? extends V after ); // 复合转换 解释说明         Function 是功能的意思可以将一种数据类型的对象转换为另一种数据类型的对象至于如何转换就需要看这个接口被如何实现。 示例 import java . util . function . Function ; public class FunctionTest {         public static void main ( String [] args ) {                 // FunctionString,Integer f1 new FunctionString, Integer() {                         // Override                         // public Integer apply(String s) {                                 // return Integer.parseInt(s);                         // }                 // };                 // FunctionString,Integer f1 s - Integer.parseInt(s);                 Function String , Integer f1 Integer :: parseInt ;                 Integer i f1 . apply ( 123 );                 System . out . println ( i );                 // FunctionInteger,Double f2 new FunctionInteger, Double() {                         // Override                         // public Double apply(Integer integer) {                                 // return integer * 10.0;                         // }                 // };                 Function Integer , Double f2 integer - integer * 10.0 ;                 System . out . println ( f2 . apply ( i ));                 Function String , Double f3 f1 . andThen ( f2 );                 double d f3 . apply ( 5 );                 System . out . println ( d );         } } 练习 现有文本存储学生信息如下 谢霆锋 , 男 ,37 刘德华 , 男 ,52 郭富城 , 男 ,46 张学友 , 男 ,40 要求将学生信息从文本中读取出来并转换为学生对象然后存储在集合中 import java . io . BufferedReader ; import java . io . FileNotFoundException ; import java . io . FileReader ; import java . io . IOException ; import java . util . ArrayList ; import java . util . List ; import java . util . function . Function ; public class Exercise {         public static void main ( String [] args ) {                 String path F:/stu.txt ;                 // FunctionString, Student function new FunctionString, Student() {                         // Override                         // public Student apply(String s) {                                 // return new Student(s.split(,));                         // }                 // };                 Function String , Student function s - new                 Student ( s . split ( , ));                 List Student students readStudent ( path , function );                 students . forEach ( System . out :: println );                 System . out . println ( );                 // FunctionString[], Student f new FunctionString[], Student () {                         // Override                         // public Student apply(String[] strings) {                                 // return new Student(strings);                         // }                 // };                 // FunctionString[], Student f strings - new Student(strings);                 Function String [], Student f Student :: new ;                 List Student stus readStudent1 ( path , f );                 stus . forEach ( System . out :: println );         }         public static List Student readStudent1 ( String path ,                 Function String [], Student function ){                 List Student students new ArrayList ();                 try ( FileReader reader new FileReader ( path );                         BufferedReader br new BufferedReader ( reader )) {                         String line ;                         while (( line br . readLine ()) ! null ){                                 String [] arr line . split ( , );                                 Student stu function . apply ( arr );                                 students . add ( stu );                         }                 } catch ( FileNotFoundException e ) {                         e . printStackTrace ();                 } catch ( IOException e ) {                         e . printStackTrace ();                 }                 return students ;         }         public static List Student readStudent ( String path , Function String , Student function ){                 List Student students new ArrayList ();                 try ( FileReader reader new FileReader ( path );                         BufferedReader br new BufferedReader ( reader )) { String line ;                         while (( line br . readLine ()) ! null ){                                 Student stu function . apply ( line );                                 students . add ( stu );                         }                 } catch ( FileNotFoundException e ) {                         e . printStackTrace ();                 } catch ( IOException e ) {                         e . printStackTrace ();                 }                 return students ;         }         private static class Student {                 private String name ;                 private String sex ;                 private int age ;        public Student ( String [] arr ) {                 this . name arr [ 0 ];                 this . sex arr [ 1 ];                 this . age Integer . parseInt ( arr [ 2 ]);         }         public String getName () {                 return name ;         }         public void setName ( String name ) {                 this . name name ;         }         public String getSex () {                 return sex ;         }         public void setSex ( String sex ) {                 this . sex sex ;         }         public int getAge () {                 return age ;         }         public void setAge ( int age ) {                 this . age age ;         }         Override         public String toString () {                 return Student{                         name name \                         , sex sex \                         , age age                         } ;         } } }
文章转载自:
http://www.morning.mrncd.cn.gov.cn.mrncd.cn
http://www.morning.qhmql.cn.gov.cn.qhmql.cn
http://www.morning.zkgpg.cn.gov.cn.zkgpg.cn
http://www.morning.srgbr.cn.gov.cn.srgbr.cn
http://www.morning.mbpfk.cn.gov.cn.mbpfk.cn
http://www.morning.jfjfk.cn.gov.cn.jfjfk.cn
http://www.morning.mnkz.cn.gov.cn.mnkz.cn
http://www.morning.pgxjl.cn.gov.cn.pgxjl.cn
http://www.morning.stcds.cn.gov.cn.stcds.cn
http://www.morning.wnzgm.cn.gov.cn.wnzgm.cn
http://www.morning.lhrcr.cn.gov.cn.lhrcr.cn
http://www.morning.mcjxq.cn.gov.cn.mcjxq.cn
http://www.morning.yhrfg.cn.gov.cn.yhrfg.cn
http://www.morning.jkzjs.cn.gov.cn.jkzjs.cn
http://www.morning.pphgl.cn.gov.cn.pphgl.cn
http://www.morning.ypdmr.cn.gov.cn.ypdmr.cn
http://www.morning.jtmrx.cn.gov.cn.jtmrx.cn
http://www.morning.tymnr.cn.gov.cn.tymnr.cn
http://www.morning.dpwcl.cn.gov.cn.dpwcl.cn
http://www.morning.jrlgz.cn.gov.cn.jrlgz.cn
http://www.morning.slwfy.cn.gov.cn.slwfy.cn
http://www.morning.ldpjm.cn.gov.cn.ldpjm.cn
http://www.morning.qlsyf.cn.gov.cn.qlsyf.cn
http://www.morning.nfccq.cn.gov.cn.nfccq.cn
http://www.morning.rwbx.cn.gov.cn.rwbx.cn
http://www.morning.spdyl.cn.gov.cn.spdyl.cn
http://www.morning.nlkhr.cn.gov.cn.nlkhr.cn
http://www.morning.gbsfs.com.gov.cn.gbsfs.com
http://www.morning.qcymf.cn.gov.cn.qcymf.cn
http://www.morning.pkrtz.cn.gov.cn.pkrtz.cn
http://www.morning.bmtyn.cn.gov.cn.bmtyn.cn
http://www.morning.yesidu.com.gov.cn.yesidu.com
http://www.morning.rongxiaoman.com.gov.cn.rongxiaoman.com
http://www.morning.hxbjt.cn.gov.cn.hxbjt.cn
http://www.morning.kfwqd.cn.gov.cn.kfwqd.cn
http://www.morning.hkpn.cn.gov.cn.hkpn.cn
http://www.morning.pxtgf.cn.gov.cn.pxtgf.cn
http://www.morning.zzfjh.cn.gov.cn.zzfjh.cn
http://www.morning.dxrbp.cn.gov.cn.dxrbp.cn
http://www.morning.ndltr.cn.gov.cn.ndltr.cn
http://www.morning.zmpqh.cn.gov.cn.zmpqh.cn
http://www.morning.pgjyc.cn.gov.cn.pgjyc.cn
http://www.morning.xcfmh.cn.gov.cn.xcfmh.cn
http://www.morning.xqcbz.cn.gov.cn.xqcbz.cn
http://www.morning.jycr.cn.gov.cn.jycr.cn
http://www.morning.thzwj.cn.gov.cn.thzwj.cn
http://www.morning.lbfgq.cn.gov.cn.lbfgq.cn
http://www.morning.mljtx.cn.gov.cn.mljtx.cn
http://www.morning.qxwwg.cn.gov.cn.qxwwg.cn
http://www.morning.ljbch.cn.gov.cn.ljbch.cn
http://www.morning.smdiaosu.com.gov.cn.smdiaosu.com
http://www.morning.ysfj.cn.gov.cn.ysfj.cn
http://www.morning.tkzrh.cn.gov.cn.tkzrh.cn
http://www.morning.chfxz.cn.gov.cn.chfxz.cn
http://www.morning.rwlnk.cn.gov.cn.rwlnk.cn
http://www.morning.tdxnz.cn.gov.cn.tdxnz.cn
http://www.morning.bqqzg.cn.gov.cn.bqqzg.cn
http://www.morning.pghgq.cn.gov.cn.pghgq.cn
http://www.morning.fdzzh.cn.gov.cn.fdzzh.cn
http://www.morning.bksbx.cn.gov.cn.bksbx.cn
http://www.morning.tmrjb.cn.gov.cn.tmrjb.cn
http://www.morning.xqffq.cn.gov.cn.xqffq.cn
http://www.morning.gqwpl.cn.gov.cn.gqwpl.cn
http://www.morning.cbtn.cn.gov.cn.cbtn.cn
http://www.morning.zwzwn.cn.gov.cn.zwzwn.cn
http://www.morning.jopebe.cn.gov.cn.jopebe.cn
http://www.morning.wwdlg.cn.gov.cn.wwdlg.cn
http://www.morning.tqjwx.cn.gov.cn.tqjwx.cn
http://www.morning.glrzr.cn.gov.cn.glrzr.cn
http://www.morning.pmtky.cn.gov.cn.pmtky.cn
http://www.morning.hdwjb.cn.gov.cn.hdwjb.cn
http://www.morning.cffwm.cn.gov.cn.cffwm.cn
http://www.morning.zxqxx.cn.gov.cn.zxqxx.cn
http://www.morning.lzwfg.cn.gov.cn.lzwfg.cn
http://www.morning.twmp.cn.gov.cn.twmp.cn
http://www.morning.kpmxn.cn.gov.cn.kpmxn.cn
http://www.morning.qzglh.cn.gov.cn.qzglh.cn
http://www.morning.wqpsf.cn.gov.cn.wqpsf.cn
http://www.morning.wlxfj.cn.gov.cn.wlxfj.cn
http://www.morning.lzsxp.cn.gov.cn.lzsxp.cn
http://www.tj-hxxt.cn/news/254810.html

相关文章:

  • seo关键词平台网站的后续优化方案
  • 可以建网站的网络公司有哪些网络管理系统官网
  • 网站建设制作报价方案加强部门网站建设工作总结
  • 快站科技是什么东莞最穷的三个镇
  • seo网站优化策划书玉林英文网站建设
  • 网站三合一政法门户网站建设情况
  • 国内新闻最新消息10条2021有强大seo功能的wordpress模板
  • 网站设计苏州成都美食网站设计论文
  • 评价一个网站的好坏免费网络推广平台有哪些
  • 做外贸网站公司盐山县网站建设
  • 如何为网站做面包屑导航个人免费空间申请
  • 上海网站推广系统淄博seo推广
  • 检察网站建设请示百度小说风云榜排名
  • 免费网站站wordpress+新打开空白
  • 早期做的网站支持现在的网速吗网站程序 seo
  • 安徽专业建网站泰安百度网站建设
  • 重庆网站建设jwzcq虚拟主机比较
  • 专题文档dede企业网站建设中国企业500强最新排名名单
  • 网站建设欧美.net网站与php网站
  • 免费flash网站模板天天ae模板网
  • 咸阳网站建设费用树莓派可以做网站的服务器吗
  • 济南网站制作厂家百度做广告
  • 公司网站要多少钱提供手机自适应网站公司
  • wap网站还用吗网站开发概述
  • 烟台网站建设找企汇互联专业wordpress 证书
  • 骗别人做网站网站建设 搜狐
  • 广东睿营建设有限公司网站做药物分析网站
  • 吉林省长春网站建设企业建网站报价
  • 网站开发 工作量评估茂名网站建设方案开发
  • 建设安全备案登入那个网站手机制作模板图片的app