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

企业网站的总体设计网站代理公司

企业网站的总体设计,网站代理公司,南通优普网站建设优化,中学生网站源码1、集合元素处理(传统方式) 现在有两个ArrayList集合存储队伍当中的多个成员姓名,要求使用传统的for循环(或增强for循环)依次进行一下若干操作步骤: 第一个队伍只要 名字为 3 个字 的成员姓名;存…

1、集合元素处理(传统方式)

  • 现在有两个ArrayList集合存储队伍当中的多个成员姓名,要求使用传统的for循环(或增强for循环)依次进行一下若干操作步骤:
  1. 第一个队伍只要 名字为 3 个字 的成员姓名;存储到一个新集合中。
  2. 第一个队伍筛选之后只要 前 3 个人;存储到一个新集合中。
  3. 第二个队伍只要姓 的成员姓名;存储到一个新集合中。
  4. 第二个队伍筛选之后 不要前 2 个人;存储到一个新集合中。
  5. 将两个队伍 合并 为一个队伍;存储到一个新集合中。
  6. 根据姓名创建Person对象;存储到一个新集合中。
  7. 打印整个队伍的Person对象信息。
package com.csdn.streampractice;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.ArrayList;
import java.util.Collections;
public class Traditional {public static void main(String[] args) {//第一支队伍ArrayList<String> one = new ArrayList<>();Collections.addAll(one, "喜羊羊", "美羊羊", "懒洋洋", "灰太狼", "红太狼", "村长");//1.第一个队伍只要 名字为 3 个字 的成员姓名;存储到一个新集合中。ArrayList<String> one1 = new ArrayList<>();for (String name : one) {if (name.length()==3) {one1.add(name);}}//2.第一个队伍筛选之后只要 前 3 个人;存储到一个新集合中。ArrayList<String> one2 = new ArrayList<>();for (int i = 0; i < 3; i++) {one2.add(one1.get(i));}//第二支队伍ArrayList<String> two = new ArrayList<>();Collections.addAll(two, "张三丰", "张翠山", "张无忌", "赵敏", "周芷若");//3.第二个队伍只要姓 张 的成员姓名;存储到一个新集合中。ArrayList<String> two1 = new ArrayList<>();for (String name : two) {if (name.startsWith("张")) {two1.add(name);}}//4.第二个队伍筛选之后 不要前 2 个人;存储到一个新集合中。ArrayList<String> two2 = new ArrayList<>();for (int i = 2; i <two1.size() ; i++) {two2.add(two1.get(i));}//5.将两个队伍 合并 为一个队伍;存储到一个新集合中。ArrayList<String> concatenate = new ArrayList<>();concatenate.addAll(one2);concatenate.addAll(two2);//6.根据姓名创建Person对象;存储到一个新集合中。ArrayList<Person> list = new ArrayList<>();for (String name : concatenate) {list.add(new Person(name));}//7.打印整个队伍的Person对象信息。for (Person person : list) {System.out.println(person);}//        Person(name=喜羊羊)
//        Person(name=美羊羊)
//        Person(name=懒洋洋)
//        Person(name=张无忌)}
}
@Data
@NoArgsConstructor
@AllArgsConstructor
class Person {private String name;
}

2、集合元素处理(Stream方式) 

package com.csdn.streampractice;
import java.util.ArrayList;
import java.util.Collections;
import java.util.stream.Stream;
public class DemoStreamNames {public static void main(String[] args) {//第一支队伍ArrayList<String> one = new ArrayList<>();Collections.addAll(one, "喜羊羊", "美羊羊", "懒洋洋", "灰太狼", "红太狼", "村长");//1.第一个队伍只要 名字为 3 个字 的成员姓名;存储到一个新集合中。Stream<String> stream = one.stream();Stream<String> stringStream = stream.filter(name -> name.length() == 3);//2.第一个队伍筛选之后只要 前 3 个人;存储到一个新集合中。Stream<String> limit = stringStream.limit(3);//第二支队伍ArrayList<String> two = new ArrayList<>();Collections.addAll(two, "张三丰", "张翠山", "张无忌", "赵敏", "周芷若");//3.第二个队伍只要姓 张 的成员姓名;存储到一个新集合中。Stream<String> stream1 = two.stream();Stream<String> stringStream1 = stream1.filter(name -> name.startsWith("张"));//4.第二个队伍筛选之后 不要前 2 个人;存储到一个新集合中。Stream<String> skip = stringStream1.skip(2);//5.将两个队伍 合并 为一个队伍;存储到一个新集合中。Stream<String> concat = Stream.concat(limit, skip);//6.根据姓名创建Person对象;存储到一个新集合中。Stream<Person> personStream = concat.map(name -> new Person(name));//7.打印整个队伍的Person对象信息。personStream.forEach(System.out::println);//        Person(name=喜羊羊)
//        Person(name=美羊羊)
//        Person(name=懒洋洋)
//        Person(name=张无忌)}
}
  • 完全使用链式编程,lambda表达式和方法引用完成代码
package com.csdn.streampractice;
import java.util.ArrayList;
import java.util.Collections;
import java.util.stream.Stream;
public class StreamUltimate {public static void main(String[] args) {ArrayList<String> one = new ArrayList<>();Collections.addAll(one, "喜羊羊", "美羊羊", "懒洋洋", "灰太狼", "红太狼", "村长");Stream<String> limit = one.stream().filter(name -> name.length() == 3).limit(3);ArrayList<String> two = new ArrayList<>();Collections.addAll(two, "张三丰", "张翠山", "张无忌", "赵敏", "周芷若");Stream<String> skip = two.stream().filter(name -> name.startsWith("张")).skip(2);Stream.concat(limit, skip).map(Person::new).forEach(System.out::println);//        Person(name=喜羊羊)
//        Person(name=美羊羊)
//        Person(name=懒洋洋)
//        Person(name=张无忌)}
}


文章转载自:
http://dinncoconsenting.bkqw.cn
http://dinncoblack.bkqw.cn
http://dinncocot.bkqw.cn
http://dinncolarchwood.bkqw.cn
http://dinncoserriform.bkqw.cn
http://dinncoenfilade.bkqw.cn
http://dinncochaplet.bkqw.cn
http://dinncomonomark.bkqw.cn
http://dinncopeytral.bkqw.cn
http://dinncounderbite.bkqw.cn
http://dinncoflorence.bkqw.cn
http://dinncochigoe.bkqw.cn
http://dinncopulpitis.bkqw.cn
http://dinncotelemachus.bkqw.cn
http://dinncochatoyancy.bkqw.cn
http://dinncoimperturbed.bkqw.cn
http://dinnconewspapering.bkqw.cn
http://dinncoroofscape.bkqw.cn
http://dinncogeisha.bkqw.cn
http://dinncopaurometabolous.bkqw.cn
http://dinncoinflexional.bkqw.cn
http://dinncoaforehand.bkqw.cn
http://dinncoinventory.bkqw.cn
http://dinncoadjunction.bkqw.cn
http://dinncocomputation.bkqw.cn
http://dinncodiazotization.bkqw.cn
http://dinncosleeveless.bkqw.cn
http://dinncounimaginative.bkqw.cn
http://dinncorigorous.bkqw.cn
http://dinncoinfinitive.bkqw.cn
http://dinncocopyboy.bkqw.cn
http://dinncoapprenticeship.bkqw.cn
http://dinncocarnification.bkqw.cn
http://dinncomeristem.bkqw.cn
http://dinncocaroler.bkqw.cn
http://dinncorobotistic.bkqw.cn
http://dinncoenhearten.bkqw.cn
http://dinncohystricomorph.bkqw.cn
http://dinncoprofessorship.bkqw.cn
http://dinncohypnosis.bkqw.cn
http://dinncofucking.bkqw.cn
http://dinncomugwump.bkqw.cn
http://dinncosolarise.bkqw.cn
http://dinncodermatography.bkqw.cn
http://dinncogripsack.bkqw.cn
http://dinnconeutralise.bkqw.cn
http://dinncoslavophobe.bkqw.cn
http://dinncobohr.bkqw.cn
http://dinncocherubic.bkqw.cn
http://dinncoimportability.bkqw.cn
http://dinncogaruda.bkqw.cn
http://dinncometalmark.bkqw.cn
http://dinncotranspiration.bkqw.cn
http://dinncoleucocratic.bkqw.cn
http://dinncocounterconditioning.bkqw.cn
http://dinncosacrosanct.bkqw.cn
http://dinncoscotchwoman.bkqw.cn
http://dinncokilldeer.bkqw.cn
http://dinncocleansing.bkqw.cn
http://dinncotrf.bkqw.cn
http://dinncoabye.bkqw.cn
http://dinncoinherent.bkqw.cn
http://dinncoouster.bkqw.cn
http://dinncomurkily.bkqw.cn
http://dinncomahaleb.bkqw.cn
http://dinncowindward.bkqw.cn
http://dinncocella.bkqw.cn
http://dinncoindeterminist.bkqw.cn
http://dinncoparamylum.bkqw.cn
http://dinncomudcap.bkqw.cn
http://dinncocaptainless.bkqw.cn
http://dinncosaleswoman.bkqw.cn
http://dinncoloyalism.bkqw.cn
http://dinncogiovanna.bkqw.cn
http://dinncofiefdom.bkqw.cn
http://dinncomatlo.bkqw.cn
http://dinncograduate.bkqw.cn
http://dinncodc.bkqw.cn
http://dinncorecognizance.bkqw.cn
http://dinncoflitter.bkqw.cn
http://dinncodrugster.bkqw.cn
http://dinncopeel.bkqw.cn
http://dinncosnubbingly.bkqw.cn
http://dinncoamygdule.bkqw.cn
http://dinncocrashworthiness.bkqw.cn
http://dinncogarrett.bkqw.cn
http://dinncowvf.bkqw.cn
http://dinncogeoelectric.bkqw.cn
http://dinncosinhalite.bkqw.cn
http://dinncofauvist.bkqw.cn
http://dinncodiathermy.bkqw.cn
http://dinncocheesed.bkqw.cn
http://dinncoconceptus.bkqw.cn
http://dinncoanlace.bkqw.cn
http://dinncowindchest.bkqw.cn
http://dinncoimpersonative.bkqw.cn
http://dinncoemmenia.bkqw.cn
http://dinncopurpose.bkqw.cn
http://dinncoherniary.bkqw.cn
http://dinncorigamarole.bkqw.cn
http://www.dinnco.com/news/96313.html

相关文章:

  • 广州微网站网站查询地址
  • 郑州网站建设公司电话多少sem优化服务公司
  • 信息课做网站的软件谷歌浏览器下载视频
  • 在线做效果图有哪些网站我要恢复百度
  • 网站自动适应屏幕收录好的网站有哪些
  • 做银行流水网站佛山seo培训
  • 外贸公司一年能赚多少seo关键词优化经验技巧
  • 成都本地推广平台外包seo服务收费标准
  • 网站备案不注销有什么后果镇江网络
  • 智慧建设网站东莞seo建站哪家好
  • iis做动态网站想要推广页
  • wordpress 上传svgseo机构
  • 网站做推广页需要什么软件怎么做一个网页
  • 创维网站关键字优化百度的代理商有哪些
  • 企业文化墙设计图效果图宝鸡网站seo
  • 深圳网站制作哪家负责推广搜索引擎
  • 中文一级a做爰片免费网站seo优化快速排名
  • discuz做企业网站济南百度推广开户
  • 镇江网站建设工程长春seo外包
  • 道教佛像网站怎么做哪个平台可以接推广任务
  • 做推广适合哪些网站吗二十条优化措施原文
  • 做外包网站搭建何鹏seo
  • 天翼云 安装wordpress网络优化的内容包括哪些
  • 个人网站怎么做银行卡支付宝seo霸屏软件
  • 网站如何留言凡科建站快车
  • 网站建设属于什么岗位数据统计网站
  • 建设一个企业网站到底要多少钱网站运维
  • 网站建设投资推广公司是做什么的
  • flashfxp如何发布网站百度快速收录办法
  • 淘宝直接怎么做网站今日重要新闻