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

网站建设备案审核要多久域名怎么建设网站

网站建设备案审核要多久,域名怎么建设网站,企业商标图案大全,广州网站建设有哪些公司一、概述 有两种不同的方法来实现List接口。ArrayList类使用基于连续内存分配的实现#xff0c;而LinkedList实现基于linked allocation。 list接口提供了一些方法#xff1a; 二、The ArrayList and LinkedList Classes 1.构造方法 这两个类有相似的构造方法#xff1a…一、概述 有两种不同的方法来实现List接口。ArrayList类使用基于连续内存分配的实现而LinkedList实现基于linked allocation。 list接口提供了一些方法 二、The ArrayList and LinkedList Classes 1.构造方法 这两个类有相似的构造方法 ArrayList()ArrayList(int initialCapacity)ArrayList(Collection? extends E c) LinkedList()LinkedList(Collection? extends E c) 使用第三种构造方法可以将list转为arraylist import java.util.ArrayList; import java.util.Arrays; import java.util.List;public class ArrayListDemo {public static void main(String[] args) {// 创建一个包含一些整数的列表ListInteger numbers Arrays.asList(1, 2, 3, 4, 5);// 使用 ArrayList(Collection? extends E c) 构造方法创建一个新的 ArrayList 对象ArrayListInteger arrayList new ArrayList(numbers);// 打印 ArrayList 的内容System.out.println(arrayList);} } 用for循环将数组转为linkedlist  // Initialize array of names.String [] namesArray {Anna, Bob, Carlos, Debby};// Create empty list.LinkedListString list1 new LinkedList();// Populate the list using a loop.for (String s : namesArray){list1.add(s);}System.out.println(list1); 注意java中的collection都自带toString方法结果如下 [Anna, Bob, Carlos, Debby] 2.asList 我们可以不用for循环遍历而直接把一个array转化为linkedlist或arraylist // Initialize array of names. String[] namesArray {Anna, Bob, Carlos, Debby};// Create LinkedList from array using constructor.LinkedListString linkedList new LinkedList(Arrays.asList(namesArray)); 也可以这样 LinkedList list2 new LinkedList(Arrays.asList(Anna, Bob, Carlos, Debby)); 3.linkedlist中的其他方法  三、List Iterators 迭代器可以在列表中向前或向后移动。除了 next() 方法外列表迭代器还有一个 previous() 方法列表迭代器有一个光标位置它总是位于调用 previous() 方法返回的元素和调用 next() 方法返回的元素之间。 最初光标位于索引为 0 的元素之前。调用 next() 时光标将返回索引为 0 的元素并越过返回的元素向前移动到元素 0 和元素 1 之间的位置。此时调用 previous() 将返回元素 0并将光标移回起点但调用 next() 将返回元素 1并将光标向前移动到元素 1 和元素 2 之间的位置。如果光标已经越过最后一个元素调用 next() 将抛出 NoSuchElementException 异常。同样如果光标位置在元素 0 之前调用 previous() 也会产生同样的异常。 列表迭代器中的 remove() 方法会从列表中删除最后一次调用 next() 或 previous() 时返回的元素。 也就是说如果在调用 remove() 方法之前没有先调用 next() 或 previous() 方法那么会抛出一个 IllegalStateException 异常。 这是因为 remove() 方法的作用是删除迭代器最后访问的元素所以在调用 remove() 方法之前必须先调用 next() 或 previous() 方法以确保迭代器已经指向了要删除的元素。 如果在调用 remove() 方法之前没有先调用 next() 或 previous() 方法那么迭代器没有指向任何元素也就无法删除元素因此会抛出 IllegalStateException 异常。 这里的迭代器的remove方法和list的remove方法不是一个东西自然不能按原来的方式理解。 list的迭代器还提供了以下方法 例子 import java.util.*;/*** Demonstrates the list iterator*/ public class ListIteratorDemo {public static void main(String[] args) {// Create an array list to hold strings.String[] names {Chris, David, Katherine, Kenny};ListString nameList new ArrayList(Arrays.asList(names));// Display the names in the list.System.out.println(Here are the original names.);System.out.println(nameList);// Get a list iterator.ListIteratorString it nameList.listIterator();// Add Darlene to the list right after Chris.while (it.hasNext()) {String str it.next();// If the last name retrieved was Chris// then insert Darlene.if (str.equalsIgnoreCase(Chris)) {it.add(Darlene);// We are donebreak;}}//Display the names in the list again.System.out.println(\nHere are the new names now.);System.out.println(nameList);} } Here are the original names. [Chris, David, Katherine, Kenny] Here are the new names now. [Chris, Darlene, David, Katherine, Kenny] 四、用list接口变量去引用linkedlist或arraylist 推荐使用 ListString nameList new ArrayList(); 而不是 ArrayListString nameList new ArrayList(); 因为第一种方法后期容易修改。 比如在后期发现namelist实际上应该使用linkedlist这是只需要把第一句改成 ListString myList new LinkedList(); 这时项目中所有的myList就都变成了Linkedlist。 如果用第二种方法我们在项目中别的地方传参的时候会传入arraylist nameList这时如果要换成Linkedlist我们需要改变所有传入参数的类型。 使用第一种方法我们传的参数是List nameList就不需改变。
http://www.w-s-a.com/news/691103/

相关文章:

  • 优惠券推广网站怎么做青岛正规网站建设哪家便宜
  • 怎么搞一个服务器建设网站wordpress页眉编辑
  • 计算机企业网站建设论文流量平台是什么意思
  • 成都建设网站公司哪家好上海有名的广告公司
  • 收录优美图片找不到了整站seo优化一般多少钱
  • 大型网站建设哪家好汉川网页设计
  • 深圳品牌策划公司推荐南昌网站怎么做seo
  • 滨州做微商城网站备案时暂时关闭网站
  • 手机网站样式代码网站是怎样制作的
  • 任务发布网站建设苏州园区房价
  • 网站的认识知识付费做的最好的平台
  • 企业电子商务网站设计的原则深圳的网站建设公司怎么样
  • 个人网站趋向wordpress图片搬家
  • 做空压机网站的公司有哪些wordpress 外部链接
  • 网站建设管理成本估计小红书推广平台
  • 一级a做爰片免费观看网站焦作建设企业网站公司
  • 欧阳网站建设2022华为云营销季
  • 快速学做网站高水平的大连网站建设
  • 专业做房地产网站建设wordpress侧面小工具
  • 旅游网站开发的重要性wordpress添加广告插件
  • 关于网站建设管理工作的报告婚纱网站php
  • 东莞市建设培训中心网站那个网站可以看高速的建设情况
  • 网站开发工具安卓版专业小程序商城开发
  • 网站不备案影响收录吗深圳住房网站app
  • 交网站建设域名计入什么科目开发平台教程
  • 个人网站定制北京快速建站模板
  • 河南海华工程建设监理公司网站高端论坛网站建设
  • 网站建设网络推广方案图片编辑器免费
  • 如何用dw做网站设计设计头条
  • 网站建设基础及流程北京商场购物中心排名