当前位置:网站首页>数组相关的知识点
数组相关的知识点
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自定义分区实现
- PyQt5快速开发与实战 4.11 拖曳与剪贴板
- GKObstacle
- Operation log of dbeaver
- Yarn报错:Exception message: /bin/bash: line 0: fg: no job control
- OCR knowledge summary
- Install Office customization. Troubleshooting during installation
- Yarn报错:Could not find any valid local directory for nmPrivate/
- SQL Server 2016 learning record - nested query
- Test question discovery ring of previous test questions
猜你喜欢
![[application of stack] - infix expression to suffix expression](/img/c1/879716342f6dd5eaa8b79c752eca16.png)
[application of stack] - infix expression to suffix expression

Markdown to word or PDF

Machine learning -- handwritten English alphabet 2 -- importing and processing data

安装office自定义项 安装期间出错 解决办法

蓝桥杯嵌入式-HAL库-USART_RX

Pyqt5 rapid development and practice 4.13 menu bar, toolbar and status bar and 4.14 qprinter

Attention 注意力机制流程框图

GKCylindersNoiseSource

AP AUTOSAR platform design 3 architecture

Attention attention mechanism flow chart
随机推荐
Codeforces Round #614 (Div. 2) A. ConneR and the A.R.C. Markland-N
GKPolygonObstacle
蓝桥杯电子类嵌入式第十届省赛
Using k-means clustering to classify tariff models of different industries
Causes and solutions of invalid ROM table
Machine learning -- handwritten English alphabet 1 -- classification process
STM32中的APB2和APB1
GKRandomSource
GKVoronoiNoiseSource
GKCylindersNoiseSource
20200229 training match L1 - 2 delete the substring in the string (20 points)
Yan reported an error: could not find any valid local directory for nmprivate/
ACM winter vacation training 4
GKNoiseSource
AP AUTOSAR platform design 3 architecture
Machine learning -- handwritten English alphabet 2 -- importing and processing data
287. Find the Duplicate Number
判断数码管是共阳极还是共阴极
10_ UE4 advanced_ Add fall and cast actions
Yarn报错:Could not find any valid local directory for nmPrivate/