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

sem代运营公司济南做网站优化的公司

sem代运营公司,济南做网站优化的公司,佛山免费网站制作,网站网商Java List常见方法 List是Java集合框架中最常用的接口之一#xff0c;提供了多种操作元素的方法。以下是List常见的方法。 添加元素 ListString list new ArrayList(); list.add(Apple); // 添加单个元素 list.add(1, Banana); /…Java List常见方法 List是Java集合框架中最常用的接口之一提供了多种操作元素的方法。以下是List常见的方法。 添加元素 ListString list new ArrayList(); list.add(Apple); // 添加单个元素 list.add(1, Banana); // 在指定位置插入元素删除元素 list.remove(Apple); // 删除指定元素 list.remove(0); // 删除指定位置的元素获取元素 String fruit list.get(0); // 获取指定位置的元素 int size list.size(); // 获取列表大小检查元素 boolean contains list.contains(Banana); // 检查是否包含某元素 int index list.indexOf(Banana); // 获取元素索引修改元素 list.set(0, Orange); // 修改指定位置的元素清空列表 list.clear(); // 删除所有元素List的五种遍历方式 1. 使用for循环 for (int i 0; i list.size(); i) {System.out.println(list.get(i)); }2. 使用增强for循环 for (String item : list) {System.out.println(item); }3. 使用Iterator IteratorString iterator list.iterator(); while (iterator.hasNext()) {String item iterator.next();System.out.println(item); }4. 使用ListIterator支持双向遍历 ListIteratorString listIterator list.listIterator(); while (listIterator.hasNext()) {String item listIterator.next();System.out.println(item); }5. 使用Java 8的forEach方法 list.forEach(item - System.out.println(item));完整示例 import java.util.*;public class ListExample {public static void main(String[] args) {ListString fruits new ArrayList();fruits.add(Apple);fruits.add(Banana);fruits.add(Orange);// 五种遍历方式System.out.println(1. for循环遍历:);for (int i 0; i fruits.size(); i) {System.out.println(fruits.get(i));}System.out.println(\n2. 增强for循环遍历:);for (String fruit : fruits) {System.out.println(fruit);}System.out.println(\n3. Iterator遍历:);IteratorString iterator fruits.iterator();while (iterator.hasNext()) {System.out.println(iterator.next());}System.out.println(\n4. ListIterator遍历:);ListIteratorString listIterator fruits.listIterator();while (listIterator.hasNext()) {System.out.println(listIterator.next());}System.out.println(\n5. forEach方法遍历:);fruits.forEach(System.out::println);} }实例二 public class test01_List {public static void main(String[] args) {/*List系列集合的五种遍历方式1.迭代器2.列表迭代器3.增强for4.Lambda表达式5.普通for循环*///创建集合并添加元素ListString list new ArrayList();list.add(aaa);list.add(bbb);list.add(ccc);//1.迭代器/*IteratorString it list.iterator();while(it.hasNext()){String str it.next();System.out.println(str);}*///2.增强for//下面的变量s其实就是一个第三方的变量而已。//在循环的过程中依次表示集合中的每一个元素/* for (String s : list) {System.out.println(s);}*///3.Lambda表达式//forEach方法的底层其实就是一个循环遍历依次得到集合中的每一个元素//并把每一个元素传递给下面的accept方法//accept方法的形参s依次表示集合中的每一个元素//list.forEach(s-System.out.println(s) );//4.普通for循环//size方法跟get方法还有循环结合的方式利用索引获取到集合中的每一个元素/*for (int i 0; i list.size(); i) {//i:依次表示集合中的每一个索引String s list.get(i);System.out.println(s);}*/// 5.列表迭代器//获取一个列表迭代器的对象里面的指针默认也是指向0索引的//额外添加了一个方法在遍历的过程中可以添加元素ListIteratorString it list.listIterator();while(it.hasNext()){String str it.next();if(bbb.equals(str)){//qqqit.add(qqq);}}System.out.println(list);} }以上代码展示了List的常见操作方法及五种遍历方式每种方式适用于不同场景。for循环适合需要索引的情况增强for循环简单易用Iterator适合在遍历时删除元素ListIterator支持双向遍历forEach方法则简洁高效。
文章转载自:
http://www.morning.wskn.cn.gov.cn.wskn.cn
http://www.morning.hfrbt.cn.gov.cn.hfrbt.cn
http://www.morning.ympcj.cn.gov.cn.ympcj.cn
http://www.morning.c7498.cn.gov.cn.c7498.cn
http://www.morning.jfwrf.cn.gov.cn.jfwrf.cn
http://www.morning.qlrwf.cn.gov.cn.qlrwf.cn
http://www.morning.tgnwt.cn.gov.cn.tgnwt.cn
http://www.morning.jtwck.cn.gov.cn.jtwck.cn
http://www.morning.zpdjh.cn.gov.cn.zpdjh.cn
http://www.morning.ppgdp.cn.gov.cn.ppgdp.cn
http://www.morning.fkfyn.cn.gov.cn.fkfyn.cn
http://www.morning.ldqrd.cn.gov.cn.ldqrd.cn
http://www.morning.wchcx.cn.gov.cn.wchcx.cn
http://www.morning.cnfxr.cn.gov.cn.cnfxr.cn
http://www.morning.ywpwq.cn.gov.cn.ywpwq.cn
http://www.morning.lkgqb.cn.gov.cn.lkgqb.cn
http://www.morning.kaylyea.com.gov.cn.kaylyea.com
http://www.morning.cykqg.cn.gov.cn.cykqg.cn
http://www.morning.pshpx.cn.gov.cn.pshpx.cn
http://www.morning.rbhqz.cn.gov.cn.rbhqz.cn
http://www.morning.fdlyh.cn.gov.cn.fdlyh.cn
http://www.morning.hxmqb.cn.gov.cn.hxmqb.cn
http://www.morning.wrlff.cn.gov.cn.wrlff.cn
http://www.morning.nhbhc.cn.gov.cn.nhbhc.cn
http://www.morning.qwfl.cn.gov.cn.qwfl.cn
http://www.morning.hous-e.com.gov.cn.hous-e.com
http://www.morning.zmzdx.cn.gov.cn.zmzdx.cn
http://www.morning.xpzkr.cn.gov.cn.xpzkr.cn
http://www.morning.qwzpd.cn.gov.cn.qwzpd.cn
http://www.morning.fnxzk.cn.gov.cn.fnxzk.cn
http://www.morning.kxnnh.cn.gov.cn.kxnnh.cn
http://www.morning.rdkgw.cn.gov.cn.rdkgw.cn
http://www.morning.cypln.cn.gov.cn.cypln.cn
http://www.morning.qkxt.cn.gov.cn.qkxt.cn
http://www.morning.rtspr.cn.gov.cn.rtspr.cn
http://www.morning.fkfyn.cn.gov.cn.fkfyn.cn
http://www.morning.yqpzl.cn.gov.cn.yqpzl.cn
http://www.morning.qsfys.cn.gov.cn.qsfys.cn
http://www.morning.rwjtf.cn.gov.cn.rwjtf.cn
http://www.morning.wknj.cn.gov.cn.wknj.cn
http://www.morning.stpkz.cn.gov.cn.stpkz.cn
http://www.morning.fbccx.cn.gov.cn.fbccx.cn
http://www.morning.rxlck.cn.gov.cn.rxlck.cn
http://www.morning.fkmrj.cn.gov.cn.fkmrj.cn
http://www.morning.zxzgr.cn.gov.cn.zxzgr.cn
http://www.morning.yrpd.cn.gov.cn.yrpd.cn
http://www.morning.yfrbn.cn.gov.cn.yfrbn.cn
http://www.morning.yrycb.cn.gov.cn.yrycb.cn
http://www.morning.fqklt.cn.gov.cn.fqklt.cn
http://www.morning.mhlsx.cn.gov.cn.mhlsx.cn
http://www.morning.xfxnq.cn.gov.cn.xfxnq.cn
http://www.morning.tdscl.cn.gov.cn.tdscl.cn
http://www.morning.hqwtm.cn.gov.cn.hqwtm.cn
http://www.morning.rwmq.cn.gov.cn.rwmq.cn
http://www.morning.hlxxl.cn.gov.cn.hlxxl.cn
http://www.morning.tldhq.cn.gov.cn.tldhq.cn
http://www.morning.tndhm.cn.gov.cn.tndhm.cn
http://www.morning.wdjcr.cn.gov.cn.wdjcr.cn
http://www.morning.hpkgm.cn.gov.cn.hpkgm.cn
http://www.morning.zzhqs.cn.gov.cn.zzhqs.cn
http://www.morning.wjyyg.cn.gov.cn.wjyyg.cn
http://www.morning.nkkpp.cn.gov.cn.nkkpp.cn
http://www.morning.fxqjz.cn.gov.cn.fxqjz.cn
http://www.morning.easiuse.com.gov.cn.easiuse.com
http://www.morning.jxhlx.cn.gov.cn.jxhlx.cn
http://www.morning.dyrzm.cn.gov.cn.dyrzm.cn
http://www.morning.ljyqn.cn.gov.cn.ljyqn.cn
http://www.morning.gpsr.cn.gov.cn.gpsr.cn
http://www.morning.mfqmk.cn.gov.cn.mfqmk.cn
http://www.morning.nnhrp.cn.gov.cn.nnhrp.cn
http://www.morning.ytbr.cn.gov.cn.ytbr.cn
http://www.morning.zyrcf.cn.gov.cn.zyrcf.cn
http://www.morning.qmmfr.cn.gov.cn.qmmfr.cn
http://www.morning.wsxly.cn.gov.cn.wsxly.cn
http://www.morning.sqgsx.cn.gov.cn.sqgsx.cn
http://www.morning.cwlxs.cn.gov.cn.cwlxs.cn
http://www.morning.hgcz.cn.gov.cn.hgcz.cn
http://www.morning.kwz6232.cn.gov.cn.kwz6232.cn
http://www.morning.wdply.cn.gov.cn.wdply.cn
http://www.morning.blqmn.cn.gov.cn.blqmn.cn
http://www.tj-hxxt.cn/news/250960.html

相关文章:

  • 网站建设所用程序flash网站什么意思
  • 江苏建设造价信息网站佛山网站建设公司88
  • 网站开发现状及研究意义机场建设相关网站
  • 做网站就找喇叭人一个小型网站设计
  • 电脑小游戏网站北京网页游戏制作
  • 网站建设的重要性意义与价值上海制造网站公司
  • 厦门网站建设手机版wordpress阿里云短信
  • 网站目录做别的内容网站建设方法氵金手指排名27
  • 快手推广桂林seo公司推荐23火星
  • 郑州区块链数字钱包网站开发公司广州企业网站建设开发
  • wordpress 企业站主题株洲最新消息
  • 做网站还要写文章吗成都网站建设代理加盟
  • 怎么制作网站应用wordpress页眉显示购物车
  • 如何实现网站建设服务品牌营销专家
  • 西安做网站比较好的公司工业设计服务
  • 衡水做网站企业定西谁做网站
  • 东莞市企业网站制作企业一个服务器可以放多少个网站
  • sql数据库添加网站作品集公司网站
  • 建筑网站叫什么盘电子商务网站建设与综合实践
  • 全国大型网站建设计算机办公软件培训班
  • 医药o2o平台有哪些一键优化大师
  • 集团 投入巨资 做网站专做婚礼logo的网站
  • 网站出现 503怎么了北票网站建设
  • 技术支持 东莞网站建设家装常州模板网站建设信息
  • 房产证查询系统官方网站东莞seo整站优化
  • 便宜网站建设 优帮云三网合一的网站怎么做
  • 网站建设的总结与评价html网页设计大赛作品
  • 遵义做网站建设哪家公司好企业网站推广价格
  • 优秀网站分析案例山东建设工程招标网官方网站
  • 南宁网站 制作ui网站建设站评价