当前位置:网站首页>数组相关的知识点
数组相关的知识点
2022-07-28 10:28:00 【jjj34】
一.静态数组
1. .length
获取长度
int[] nums = new int [13];
int n = nums.length;二维数组
int rowlength=nums.length; // 行数
int collength = nums[0].length; //列数2.默认赋值
int -> 0
boolean -> false
3.声明
int[] name = new int [size];4.空数组为
new int [0];
输出结果:[]
二.动态数组
1.声明
ArrayList<Integer> name = new ArrayList<>();2.获取长度
int n = name.size();
3.判断是否为空
name.isEmpty();4.添加元素
(1) 不带索引
name.add(1) 默认添加在尾部
(2) 带索引
name.add(1,2) 在索引值为1的地方添加25.输出
System.out.println(name)
将会把数组中的所有元素输出,如
[1,1]6.判断数组中是否包含某个数
name.contains(n); n就是被判断的数7.移除数
name.remove(n) 移除索引值为n的数8.修改数
name.set(n,k) 将索引值为n的值修改为k9.访问数组元素
name.get(2) 访问索引值为2的值10.通过值找到索引
name.indexOf(n);
如果n存在就返回 n 的索引值,不存在就返回 -111.清除动态数组的所有值
name.clear();12.拼接两个动态数组
l1 [1,2,3]
l2 [5,6]
l1.addAll(l2);
l1 [1,2,3,5,6]边栏推荐
- 6、MapReduce自定义分区实现
- ACM winter vacation training 4
- QT generation Exe file and run without QT environment (enigma virtual box for green executable software packaging) graphic tutorial
- samba学习
- Configuring raspberry pie, process and problems encountered
- GKCircleObstacle
- GKBillowNoiseSource
- GKCheckerboardNoiseSource
- 2020 second intelligence cup preliminaries
- SDUT 2446 最终排名
猜你喜欢

GKCheckerboardNoiseSource

非关系型数据库MongoDB的特点及安装

Django celery redis send email asynchronously

Excel word simple skills sorting (continuous update ~)

GKCylindersNoiseSource

粒子群解决tsp的技术问题

AP Autosar平台设计 1-2 导言、技术范围与方法

GKBillowNoiseSource

5、Window端实现Mapreduce程序完成wordcount功能

I don't know how lucky the boy who randomly typed logs is. There must be a lot of overtime
随机推荐
Causes and solutions of invalid ROM table
7. MapReduce custom sorting implementation
20200217 training match L1 - 7 2019 is coming (20 points)
Tensorflow knowledge points
GKRandom
爱可可AI前沿推介(7.28)
The 11th Blue Bridge Cup Undergraduate group competition (20200321)
产品端数据分析思维
GKNoiseSource
Install Office customization. Troubleshooting during installation
Install mysql5.7 under centos7
Pat grade a title in September 2019
SDUT Round #9 2020-新春大作战
GKVoronoiNoiseSource
GKNoise
GKConstantNoiseSource
蓝桥杯嵌入式-HAL库-LCD
蓝桥杯嵌入式-HAL库-USART_RX
GKNoiseMap
Uni app project directory, file function introduction and development specification