集合框架-List集合的常见方法
2024-10-19 21:30:58
1 package cn.itcast.p4.list.demo;
2
3 import java.util.List;
4 import java.util.ArrayList;
5
6 public class ListDemo {
7
8 public static void main(String[] args) {
9 // TODO Auto-generated method stub
10 List list = new ArrayList();
11 show(list);
12
13 }
14
15 private static void show(List list) {
16 //添加元素
17 list.add("abc1");
18 list.add("abc2");
19 list.add("abc3");
20 System.out.println(list);
21 //插入元素。
22
23 // list.add(1,"abc9");
24
25 //删除元素。
26 // System.out.println("remove:"+list.remove(2));
27
28 //修改元素。
29 // System.out.println("ser:"+list.set(1, "abc8"));
30
31 //获取元素。
32 System.out.println("get:"+list.get(0));
33
34 //获取子列表。
35 System.out.println("sublist:"+list.subList(1, 2));
36 System.out.println(list);
37 }
38
39 }
最新文章
- AEAI ESB路由转换机制说明
- Cocos2dx集成于windows桌面窗口程序的步骤
- IntelliJ IDEA 14 SVN无法正常使用问题
- CodeForce---Educational Codeforces Round 3 The best Gift 解题报告
- Django1.7.1设置TEMPLATE_DIRS
- 提交svn报错说 有 unversioned 的文件
- python cmd模块练习
- OpenCV配置使用版
- html不常见问题汇总
- [Swift]LeetCode318. 最大单词长度乘积 | Maximum Product of Word Lengths
- Spring注解与Java元注解小结
- hdu5017 Ellipsoid (模拟退火)
- A1066. Root of AVL Tree
- 【洛谷P2860】冗余路径
- Linux之为集群内的机器设定主机名
- asp.net webapi 自定义身份验证
- rtmp简要流程
- 批量增删改";_bulk";
- Ubuntu安装UFW防火墙
- ffmpeg 合并aac格式音频文件
热门文章
- SpringBoot整合nacos启动报错:java.lang.NoClassDefFoundError: org/springframework/boot/context/properties/ConfigurationBeanFactoryMetadata
- linux(centos)系统安装activemq
- c++设计模式概述之命令
- 【LeetCode】622. Design Circular Queue 解题报告(Python & C++)
- Java编程基础
- Android物联网应用程序开发(智慧园区)—— 登录界面开发
- 通过Rancher Desktop在桌面上运行K8s
- What's new in Dubbo-go v1.5.1
- 【】JSON介绍
- SpringBoot 之 实现登录功能及登录拦截器