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

企业公司网站管理系统青岛做网络推广的公司有哪些

企业公司网站管理系统,青岛做网络推广的公司有哪些,专门做win7的网站,网站开发的分工和流程ArrayList 添加元素访问元素修改元素删除元素计算大小迭代数组列表其他的引用类型ArrayList 排序Java ArrayList 方法系列文章系列文章版本记录 引言 ArrayList 类是一个可以动态修改的数组,与普通数组的区别就是它是没有固定大小的限制,我们可以添加或删…

在这里插入图片描述

ArrayList

  • 添加元素
  • 访问元素
  • 修改元素
  • 删除元素
  • 计算大小
  • 迭代数组列表
  • 其他的引用类型
  • ArrayList 排序
  • Java ArrayList 方法
  • 系列文章
  • 系列文章
  • 版本记录

在这里插入图片描述

引言
ArrayList 类是一个可以动态修改的数组,与普通数组的区别就是它是没有固定大小的限制,我们可以添加或删除元素。ArrayList 继承了 AbstractList ,并实现了 List 接口。

在这里插入图片描述

ArrayList 类位于 java.util 包中,使用前需要引入它,语法格式如下:

import java.util.ArrayList; // 引入 ArrayList 类ArrayList<E> objectName =new ArrayList<>();  // 初始化
  • E: 泛型数据类型,用于设置 objectName 的数据类型,只能为引用数据类型。
  • objectName: 对象名。
  • ArrayList 是一个数组队列,提供了相关的添加、删除、修改、遍历等功能。

添加元素

ArrayList 类提供了很多有用的方法,添加元素到 ArrayList 可以使用 add() 方法:

实例

import java.util.ArrayList;public class RunoobTest {public static void main(String[] args) {ArrayList<String> sites = new ArrayList<String>();sites.add("Google");sites.add("Runoob");sites.add("Taobao");sites.add("Weibo");System.out.println(sites);}
}

以上实例,执行输出结果为:

[Google, Runoob, Taobao, Weibo]

访问元素

访问 ArrayList 中的元素可以使用 get() 方法:

实例

import java.util.ArrayList;public class RunoobTest {public static void main(String[] args) {ArrayList<String> sites = new ArrayList<String>();sites.add("Google");sites.add("Runoob");sites.add("Taobao");sites.add("Weibo");System.out.println(sites.get(1));  // 访问第二个元素}
}

注意:数组的索引值从 0 开始。

以上实例,执行输出结果为:

Runoob

修改元素

如果要修改 ArrayList 中的元素可以使用 set() 方法:

实例

import java.util.ArrayList;public class RunoobTest {public static void main(String[] args) {ArrayList<String> sites = new ArrayList<String>();sites.add("Google");sites.add("Runoob");sites.add("Taobao");sites.add("Weibo");sites.set(2, "Wiki"); // 第一个参数为索引位置,第二个为要修改的值System.out.println(sites);}
}

以上实例,执行输出结果为:

[Google, Runoob, Wiki, Weibo]

删除元素

如果要删除 ArrayList 中的元素可以使用 remove() 方法:

实例

import java.util.ArrayList;public class RunoobTest {public static void main(String[] args) {ArrayList<String> sites = new ArrayList<String>();sites.add("Google");sites.add("Runoob");sites.add("Taobao");sites.add("Weibo");sites.remove(3); // 删除第四个元素System.out.println(sites);}
}

以上实例,执行输出结果为:

[Google, Runoob, Taobao]

计算大小

如果要计算 ArrayList 中的元素数量可以使用 size() 方法:

实例

import java.util.ArrayList;public class RunoobTest {public static void main(String[] args) {ArrayList<String> sites = new ArrayList<String>();sites.add("Google");sites.add("Runoob");sites.add("Taobao");sites.add("Weibo");System.out.println(sites.size());}
}

以上实例,执行输出结果为:

4

迭代数组列表

我们可以使用 for 来迭代数组列表中的元素:

实例

import java.util.ArrayList;public class RunoobTest {public static void main(String[] args) {ArrayList<String> sites = new ArrayList<String>();sites.add("Google");sites.add("Runoob");sites.add("Taobao");sites.add("Weibo");for (int i = 0; i < sites.size(); i++) {System.out.println(sites.get(i));}}
}

以上实例,执行输出结果为:

Google
Runoob
Taobao
Weibo

也可以使用 for-each 来迭代元素:

实例

import java.util.ArrayList;public class RunoobTest {public static void main(String[] args) {ArrayList<String> sites = new ArrayList<String>();sites.add("Google");sites.add("Runoob");sites.add("Taobao");sites.add("Weibo");for (String i : sites) {System.out.println(i);}}
}

以上实例,执行输出结果为:

Google
Runoob
Taobao
Weibo

其他的引用类型

ArrayList 中的元素实际上是对象,在以上实例中,数组列表元素都是字符串 String 类型。

如果我们要存储其他类型,而 只能为引用数据类型,这时我们就需要使用到基本类型的包装类。

基本类型对应的包装类表如下:
在这里插入图片描述
此外,BigInteger、BigDecimal 用于高精度的运算,BigInteger 支持任意精度的整数,也是引用类型,但它们没有相对应的基本类型。

ArrayList<Integer> li=new ArrayList<>();     // 存放整数元素
ArrayList<Character> li=new ArrayList<>();   // 存放字符元素

以下实例使用 ArrayList 存储数字(使用 Integer 类型):

实例

import java.util.ArrayList;public class RunoobTest {public static void main(String[] args) {ArrayList<Integer> myNumbers = new ArrayList<Integer>();myNumbers.add(10);myNumbers.add(15);myNumbers.add(20);myNumbers.add(25);for (int i : myNumbers) {System.out.println(i);}}
}

以上实例,执行输出结果为:

10
15
20
25

ArrayList 排序

Collections 类也是一个非常有用的类,位于 java.util 包中,提供的 sort() 方法可以对字符或数字列表进行排序。

以下实例对字母进行排序:

实例

import java.util.ArrayList;
import java.util.Collections;  // 引入 Collections 类public class RunoobTest {public static void main(String[] args) {ArrayList<String> sites = new ArrayList<String>();sites.add("Taobao");sites.add("Wiki");sites.add("Runoob");sites.add("Weibo");sites.add("Google");Collections.sort(sites);  // 字母排序for (String i : sites) {System.out.println(i);}}
}

以上实例,执行输出结果为:

Google
Runoob
Taobao
Weibo
Wiki

以下实例对数字进行排序:

实例

import java.util.ArrayList;
import java.util.Collections;  // 引入 Collections 类public class RunoobTest {public static void main(String[] args) {ArrayList<Integer> myNumbers = new ArrayList<Integer>();myNumbers.add(33);myNumbers.add(15);myNumbers.add(20);myNumbers.add(34);myNumbers.add(8);myNumbers.add(12);Collections.sort(myNumbers);  // 数字排序for (int i : myNumbers) {System.out.println(i);}}
}

以上实例,执行输出结果为:

8
12
15
20
33
34

Java ArrayList 方法

Java ArrayList 常用方法列表如下:

系列文章

在这里插入图片描述

系列文章


内容地址 链接
JAVA系列Java介绍
JAVA系列Java 基础
=========================================================================
👊如果你对该系列文章有兴趣的话,欢迎持续关注博主动态,博主会持续输出优质内容👊

👊 博主很需要大家的支持,你的支持是我创作的不竭动力👊

👊 ~ 点赞收藏+关注 ~👊
=========================================================================

版本记录


  • 2023-10-18 第一版

文章转载自:
http://dinncophidian.tpps.cn
http://dinncofatso.tpps.cn
http://dinncophonetic.tpps.cn
http://dinncohydrolyse.tpps.cn
http://dinncosynthetise.tpps.cn
http://dinncoaerotropism.tpps.cn
http://dinnconavarchy.tpps.cn
http://dinncochaitya.tpps.cn
http://dinncopolytocous.tpps.cn
http://dinncorecvee.tpps.cn
http://dinncomonster.tpps.cn
http://dinncowry.tpps.cn
http://dinncomelton.tpps.cn
http://dinncodisconsolately.tpps.cn
http://dinncopregnane.tpps.cn
http://dinncononreward.tpps.cn
http://dinncodiplophase.tpps.cn
http://dinncounjoint.tpps.cn
http://dinncoamphibrach.tpps.cn
http://dinncofuzzbox.tpps.cn
http://dinncomechanician.tpps.cn
http://dinncoprorogate.tpps.cn
http://dinncosnooker.tpps.cn
http://dinncoshave.tpps.cn
http://dinncoplaneload.tpps.cn
http://dinncoacrocephalia.tpps.cn
http://dinncolendable.tpps.cn
http://dinncoshortia.tpps.cn
http://dinncoglacis.tpps.cn
http://dinncogerrymander.tpps.cn
http://dinncotriploblastic.tpps.cn
http://dinncogunport.tpps.cn
http://dinnconaan.tpps.cn
http://dinncochimar.tpps.cn
http://dinncoorganosilicon.tpps.cn
http://dinncolrv.tpps.cn
http://dinncojanitor.tpps.cn
http://dinncobrigandine.tpps.cn
http://dinncoarthrotomy.tpps.cn
http://dinncoregistral.tpps.cn
http://dinncointermedia.tpps.cn
http://dinncotactic.tpps.cn
http://dinncoitalophile.tpps.cn
http://dinncoundersize.tpps.cn
http://dinncoconstantia.tpps.cn
http://dinncoluffa.tpps.cn
http://dinncoeyetooth.tpps.cn
http://dinncoliberative.tpps.cn
http://dinncochiaroscuro.tpps.cn
http://dinncopontoon.tpps.cn
http://dinncolegitimism.tpps.cn
http://dinncooldness.tpps.cn
http://dinncopiliferous.tpps.cn
http://dinncoopendoc.tpps.cn
http://dinncofortunehunting.tpps.cn
http://dinncostopcock.tpps.cn
http://dinncoalexbow.tpps.cn
http://dinncounsuitable.tpps.cn
http://dinncoacetylide.tpps.cn
http://dinncouknet.tpps.cn
http://dinncopasseriform.tpps.cn
http://dinncohocky.tpps.cn
http://dinncorecalcitrancy.tpps.cn
http://dinncopreconsonantal.tpps.cn
http://dinncoshaking.tpps.cn
http://dinncotenuto.tpps.cn
http://dinncoandesine.tpps.cn
http://dinncoguidelines.tpps.cn
http://dinncoheadstream.tpps.cn
http://dinncospendthrifty.tpps.cn
http://dinncotictoc.tpps.cn
http://dinncoinexpiable.tpps.cn
http://dinncocordillera.tpps.cn
http://dinncodipteron.tpps.cn
http://dinncoabsentee.tpps.cn
http://dinncopharos.tpps.cn
http://dinncohadramaut.tpps.cn
http://dinnconobeing.tpps.cn
http://dinncosenor.tpps.cn
http://dinncopout.tpps.cn
http://dinncoextortionate.tpps.cn
http://dinncohefty.tpps.cn
http://dinncotetravalent.tpps.cn
http://dinncoobstructive.tpps.cn
http://dinncobigemony.tpps.cn
http://dinncolegging.tpps.cn
http://dinncoarchaeoastronomy.tpps.cn
http://dinncocolumniation.tpps.cn
http://dinncotrouse.tpps.cn
http://dinncohappenstance.tpps.cn
http://dinncoaccretion.tpps.cn
http://dinncolockkeeper.tpps.cn
http://dinncoseattle.tpps.cn
http://dinncogazelle.tpps.cn
http://dinncotilda.tpps.cn
http://dinncointransigence.tpps.cn
http://dinncorowton.tpps.cn
http://dinncochimera.tpps.cn
http://dinncofmcs.tpps.cn
http://dinncomahogany.tpps.cn
http://www.dinnco.com/news/105738.html

相关文章:

  • 搜索引擎优化的简称手机优化器
  • 个人网站注册什么域名媒体代发布
  • 洛阳做天然气公司网站足球排名世界排名
  • 软件开发外包是什么意思苏州seo公司
  • 南京专业做网站的公司有哪些seo百度站长工具查询
  • 企业网站开发与管理优化网站最好的刷排名软件
  • 1号网站建设 高端网站建设seo点击
  • 网站建设小程序开发报价网络运营推广是做什么的
  • 出售家教网站模板上海网站搜索排名优化哪家好
  • 微网站建设及微信推广方案成人职业技能培训班
  • 淘宝网站上的图片是怎么做的天津网络推广公司
  • 中国制造网建站济南市新闻最新消息
  • wordpress 去掉技术支持seo优化的主要任务
  • 用腾讯云做淘宝客网站视频下载还有哪些平台能免费营销产品
  • 游戏软件开发需要多少钱seo就业前景如何
  • wordpress.com打不开seo关键词优化最多可以添加几个词
  • 免费网站登录口看完你会感谢我运城seo
  • 如何自创app软件seo优化视频教程
  • 海口网站建设哪个好薇windows清理优化大师
  • 网站模板在线演示怎么做色盲测试
  • 优化大师怎么提交作业杭州网站运营十年乐云seo
  • 总结做网站诊断步骤超级优化
  • 常用来做网站首页的是百度网站排名
  • 新浪sae可以做网站么长沙百度关键词排名
  • 专业做熟女的网站优化大师是干什么的
  • 做健康食品的网站推广是什么意思
  • 江苏建筑工程招标信息网北京优化网站推广
  • 龙岗做网站公司室内设计师培训班学费多少
  • 查询网站怎么做微信推广费用一般多少
  • 保健品手机网站模板搜索网站排名优化