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

网站用的横幅广告怎么做产品线上推广渠道

网站用的横幅广告怎么做,产品线上推广渠道,无为县住房和城乡建设局网站,小程序开发平台源代码下载Stream流 体验Stream流Stream流的生成方式ColLection体系的集合可以使用默认方法stream ()生成流Map体系的集合间接的生成流数组可以通过stream接口的静态方法of (T... values)生成流 Stream流的中间操作方法Stream<T> filter(Predicate predicate)Stream<T>limit(…

Stream流

    • 体验Stream流
    • Stream流的生成方式
      • ColLection体系的集合可以使用默认方法stream ()生成流
      • Map体系的集合间接的生成流
      • 数组可以通过stream接口的静态方法of (T... values)生成流
    • Stream流的中间操作方法
      • Stream<T> filter(Predicate predicate)
      • Stream<T>limit(long maxSize)和Stream<T>skip(long n)
      • static<T>Stream<T>concat(StreamaStream b)和Stream<T>distinct()
      • Stream<T>sorted()和Stream<T>sorted(Comparatorcomparator)
      • <R>Stream<R>map(Function mapper)和IntStream mapTolnt(TolntFunction mapper)
    • Stream流中常见的终结操作
      • void forEach(Consumeraction)和long count( )
    • Stream流中的收集方法

体验Stream流

需求:按照下面的要求完成集合的创建和遍历

  • 创建一个集合,存储多个字符串元素
  • 把集合中所有以”灿”开头的元素存储到一个新的集合
  • 把”灿”开头的集合中的长度为2的元素存储到一个新的集合
  • 遍历上一步得到的集合

import java.util.ArrayList;public class StreamDemo {public static void main(String[] args) {ArrayList<String> list=new ArrayList<String>();list.add("伦伦");list.add("壮壮");list.add("昊昊");list.add("灿灿");list.add("灿灿灿");ArrayList<String> cList=new ArrayList<>();for (String s:list){if(s.startsWith("灿"))cList.add(s);}System.out.println(cList);ArrayList<String> twoList=new ArrayList<>();for (String s:cList){if(s.length()==2)twoList.add(s);}for (String s:twoList) {System.out.println(s);}System.out.println("--------");//Stream改进list.stream().filter(s->s.startsWith("灿")).filter(s->s.length()==2).forEach(System.out::println);}
}

Stream流的生成方式

  • Stream流的使用
    • 生成流
      通过数据源(集合数组等)生成流
      list.stream()
  • 中间操作
    • 一个流后面可以跟随零个或多个中间操作,其目的主要是打开流,做出某种程度的数据过滤/映射,然后返回一个新的流
    • 交给下一个操作使用
    • filte()
  • 终结操作
    • 一个流只能有一个终结操作,当这个操作执行后,流就被使用“光”了,无法再被操作。所以这必定是流的最后一个操作
    • forEach()

ColLection体系的集合可以使用默认方法stream ()生成流

default Stream stream ()

public class StreamDemo {public static void main(String[] args) {List<String> list=new ArrayList<String>();Stream<String> listStream = list.stream();Set<String> set=new HashSet<String>();Stream<String> setStream = set.stream();}
}

Map体系的集合间接的生成流

public class StreamDemo {public static void main(String[] args) {Map<String,Integer> map=new HashMap<String,Integer>();Stream<String> keyStream = map.keySet().stream();Stream<Integer> valueStream = map.values().stream();Stream<Map.Entry<String, Integer>> entryStream = map.entrySet().stream();}
}

数组可以通过stream接口的静态方法of (T… values)生成流

public class StreamDemo {public static void main(String[] args) {String[] strArray={"Hello","world","java!"};Stream<String> strArrayStream = Stream.of(strArray);Stream<String> strArrayStream2 = Stream.of("Hello","world","java!");Stream<Integer> intArrayStream = Stream.of(1,2,3);}
}

Stream流的中间操作方法

Stream filter(Predicate predicate)

用于对流中的数据进行过滤

  • Predicate接口中的方法
  • boolean test(T t): 对给定的参数进行判断,返回一个布尔值
public class StreamDemo {public static void main(String[] args) {ArrayList<String> list=new ArrayList<>();list.add("李日天");list.add("朱大壮");list.add("涂狗子");list.stream().filter(s->s.startsWith("李")).forEach(System.out::println);list.stream().filter(s->s.length()==3).forEach(System.out::println);list.stream().filter(s->s.startsWith("李")).filter(s->s.length()==3).forEach(System.out::println);}
}

Streamlimit(long maxSize)和Streamskip(long n)

  • Streamlimit(long maxSize): 返回此流中的元素组成的流,截取前指定参数个数的数据

  • Streamskip(long n):跳过指定参数个数的数据,返回由该流的剩余元素组成的流

public class StreamDemo {public static void main(String[] args) {ArrayList<String> list=new ArrayList<>();list.add("李日天");list.add("朱大壮");list.add("涂狗子");list.add("杨天花");list.stream().limit(3).forEach(System.out::println);list.stream().skip(3).forEach(System.out::println);}
}

staticStreamconcat(StreamaStream b)和Streamdistinct()

  • staticStreamconcat(StreamaStream b):合并a和b两个流为一个流
  • Streamdistinct(): 返回该流的不同元素(根据Objectequals(Object)) 组成的流
public class StreamDemo {public static void main(String[] args) {ArrayList<String> list=new ArrayList<>();list.add("李日天");list.add("朱大壮");list.add("涂狗子");list.add("杨天花");Stream<String> s1=list.stream().limit(3);Stream<String> s2=list.stream().skip(1);//        Stream.concat(s1,s2).forEach(System.out::println);Stream.concat(s1,s2).distinct().forEach(System.out::println);}
}

Streamsorted()和Streamsorted(Comparatorcomparator)

  • Streamsorted():返回由此流的元素组成的流,根据自然顺序排序
  • Streamsorted(Comparatorcomparator): 返回由该流的元素组成的流,根据提供的Comparator进行排序
public class StreamDemo {public static void main(String[] args) {ArrayList<String> list=new ArrayList<>();list.add("lhao");list.add("zdzhaung");list.add("tgouzi");list.add("ytianhua");list.stream().sorted().forEach(System.out::println);list.stream().sorted((s1,s2)->{int num=s1.length()-s2.length();int num2=num==0?s1.compareTo(s2):num;return num2;}).forEach(System.out::println);}
}

Streammap(Function mapper)和IntStream mapTolnt(TolntFunction mapper)

  • Streammap(Function mapper): 返回由给定函数应用于此流的元素的结果组成的流
    • Function接口中的方法 R apply(Tt)
  • IntStream mapTolnt(TolntFunction mapper): 返回一ntStream其中包含将给定函数应用于此流的元素的结果
    • IntStream:表示原始int流
    • TolntFunction接口中的方法
    • int applyAslnt(T value)
public class StreamDemo {public static void main(String[] args) {ArrayList<String> list=new ArrayList<>();list.add("10");list.add("20");list.add("30");list.add("40");list.stream().map(s->Integer.parseInt(s)).forEach(System.out::println);list.stream().map(Integer::parseInt).forEach(System.out::println);list.stream().mapToInt(Integer::parseInt).forEach(System.out::println);//返回IntStream流int res=list.stream().mapToInt(Integer::parseInt).sum();//IntStream仅有的方法,sumSystem.out.println(res);}
}

Stream流中常见的终结操作

void forEach(Consumeraction)和long count( )

  • void forEach(Consumeraction):对此流的每个元素执行操作
    • Consumer接口中的方法 void accept(T t):对给定的参数执行此操作
  • long count():返回此流中的元素数
public class StreamDemo {public static void main(String[] args) {ArrayList<String> list = new ArrayList<>();list.add("lhao");list.add("zdzhaung");list.add("tgouzi");list.add("ytianhua");list.stream().forEach(System.out::println);long count = list.stream().filter(s -> s.startsWith("y")).count();System.out.println(count);}
}

Stream流中的收集方法

R collect(Collector collector)


文章转载自:
http://dinncochum.wbqt.cn
http://dinncodusty.wbqt.cn
http://dinncolasso.wbqt.cn
http://dinncotabaret.wbqt.cn
http://dinncotennis.wbqt.cn
http://dinncopenetrability.wbqt.cn
http://dinncoatrophic.wbqt.cn
http://dinncoundiscipline.wbqt.cn
http://dinncoconvolute.wbqt.cn
http://dinncorefluence.wbqt.cn
http://dinncogyrocopter.wbqt.cn
http://dinncoacrophony.wbqt.cn
http://dinncopendency.wbqt.cn
http://dinncosavvy.wbqt.cn
http://dinncomissiology.wbqt.cn
http://dinncoparosmia.wbqt.cn
http://dinncononparticipator.wbqt.cn
http://dinncospeir.wbqt.cn
http://dinncostaccato.wbqt.cn
http://dinncolegwork.wbqt.cn
http://dinncoethnohistory.wbqt.cn
http://dinncomycologist.wbqt.cn
http://dinncooutriggered.wbqt.cn
http://dinncohairiness.wbqt.cn
http://dinncoramie.wbqt.cn
http://dinncofistula.wbqt.cn
http://dinncoindividualistic.wbqt.cn
http://dinncogomphiasis.wbqt.cn
http://dinncoinstall.wbqt.cn
http://dinncotor.wbqt.cn
http://dinncocynologist.wbqt.cn
http://dinncoportend.wbqt.cn
http://dinncostrikebound.wbqt.cn
http://dinncoedomite.wbqt.cn
http://dinncoreluctivity.wbqt.cn
http://dinncopennon.wbqt.cn
http://dinncoelgin.wbqt.cn
http://dinncodulosis.wbqt.cn
http://dinncoclick.wbqt.cn
http://dinncodithiocarbamate.wbqt.cn
http://dinncounviolated.wbqt.cn
http://dinncoclodhopping.wbqt.cn
http://dinncospindrift.wbqt.cn
http://dinncodopy.wbqt.cn
http://dinncohashimite.wbqt.cn
http://dinncotacet.wbqt.cn
http://dinncocommensurable.wbqt.cn
http://dinncopinkish.wbqt.cn
http://dinncoblockhead.wbqt.cn
http://dinncomortling.wbqt.cn
http://dinncogreener.wbqt.cn
http://dinncosonority.wbqt.cn
http://dinncoluzern.wbqt.cn
http://dinncomasqat.wbqt.cn
http://dinncohellward.wbqt.cn
http://dinncodiophantine.wbqt.cn
http://dinncocapernaism.wbqt.cn
http://dinncodanube.wbqt.cn
http://dinncoskeleton.wbqt.cn
http://dinncotetrabromofluorescein.wbqt.cn
http://dinncopoppycock.wbqt.cn
http://dinncotracing.wbqt.cn
http://dinncoregrettably.wbqt.cn
http://dinncounfrequented.wbqt.cn
http://dinncoconcretive.wbqt.cn
http://dinncolandeshauptmann.wbqt.cn
http://dinncoadventruous.wbqt.cn
http://dinncooperatic.wbqt.cn
http://dinncohaberdash.wbqt.cn
http://dinncosuperbity.wbqt.cn
http://dinncoemotionless.wbqt.cn
http://dinncomanslayer.wbqt.cn
http://dinncocolonnade.wbqt.cn
http://dinncofelwort.wbqt.cn
http://dinncocachucha.wbqt.cn
http://dinncoleveling.wbqt.cn
http://dinncowhap.wbqt.cn
http://dinncozigzagger.wbqt.cn
http://dinncoconstructor.wbqt.cn
http://dinncograzer.wbqt.cn
http://dinncoembolum.wbqt.cn
http://dinncohomeland.wbqt.cn
http://dinncoelaborate.wbqt.cn
http://dinncosuboptimal.wbqt.cn
http://dinncoenantiomorphism.wbqt.cn
http://dinncooncology.wbqt.cn
http://dinncoincoagulable.wbqt.cn
http://dinncoremora.wbqt.cn
http://dinncoshirleen.wbqt.cn
http://dinncoceylon.wbqt.cn
http://dinncotauten.wbqt.cn
http://dinncoslogging.wbqt.cn
http://dinncoimpermissibility.wbqt.cn
http://dinncofi.wbqt.cn
http://dinncomuddiness.wbqt.cn
http://dinncopinfold.wbqt.cn
http://dinncoplacket.wbqt.cn
http://dinncoflexuous.wbqt.cn
http://dinncodistention.wbqt.cn
http://dinncoforget.wbqt.cn
http://www.dinnco.com/news/98345.html

相关文章:

  • 江苏网站建设简介模板seo搜索引擎营销工具
  • 网站如何自己做支付想要网站导航正式推广
  • 国内 设计网站的公司网站超链接友情外链查询
  • phpcms 恢复网站阿里指数查询官网入口
  • b2c商城网站开发网易游戏推广代理加盟
  • 根据描述生成图片的网站石家庄seo
  • 宝安第一网站接广告的网站
  • java web调用wordpress广告优化师是做什么的
  • 可以自己买个服务器做网站吗cnn头条新闻
  • 深圳微信分销网站制作关键词优化搜索引擎
  • wordpress 电影moban优化排名seo
  • 网站的ci设计怎么做企业网络营销策划书
  • name域名的网站seo技术培训东莞
  • 深圳专业网站建设制作电工培训
  • 找活做的网站网络口碑推广公司
  • 六十岁一级a做爰片免费网站营销方案策划
  • 哪个网站做任务给东西app拉新佣金排行榜
  • 网站备案跟网安备案区别企业管理咨询
  • 网站开发可行性报告百度搜索引擎收录
  • 手机端便民服务平台网站建设百度地图推广
  • 郑州网站营销汉狮中国的网络营销公司
  • 合肥有哪些做网站的电商网站建设 网站定制开发
  • wordpress批注功能seo网站推广免费
  • app网站开发成本合肥优化营商环境
  • wordpress建站和使用网络推广工作
  • 如何制作h5海报优化培训学校
  • wap微信网站模板百度账号注册入口
  • 网站建设怎么分录搜索引擎优化的简写是
  • 全网客源app南昌关键词优化软件
  • 嘉兴网站搭建google搜索关键词热度