当前位置:网站首页>【day5】数组
【day5】数组
2022-07-30 06:03:00 【饮马翰海】
01_数组的概念
变量只能保存单个数据,数组可以同时保存多个数据
02_数组的定义格式一_动态初始化
03_数组的定义格式二_静态初始化
动态初始化:指定长度
静态初始化:指定内容
不管是动态初始化还是静态初始化数组都是有长度的
04_数组的定义格式三_省略的静态初始化
05_访问数组元素进行获取
06_访问数组元素进行赋值
静态初始化:其实它里面的内容先指定默认值,再指定大括号当中的默认值
07_Java中的内存划分
方法的运行一定要在栈当中运行
凡是new出来的东西都在堆当中
方法区是存储class相关信息,包含方法的信息
08_一个数组的内存图
一个数组,它的地址值不会改变
09_两个数组的内存图
shift+F6:将相同的变量都统一进行修改
10_两个引用指向同一个数组的内存图
引用类型:引用引用,引用的是它的名字
**注意:
如果我在最后,再访问一下,数组arrayA,它是0、10、20还是0、100、200呢?
答:它是0、100、200。因为它两个引用名称根本就是同一个数组
**
11_常见问题_数组索引越界异常
12_常见问题_空指针异常
13_获取数组的长度
注意看最下面的这个框
14_数组的遍历输出
for (int i = 0; i < 5; i++) //快捷输入方式:输入5.fori加回车
数组名称.fori:for(int i=0;i<array.length;i++){}
快捷输入方式:数组名称.fori
15_求出数组中的最值
16_数组元素反转
17_数组作为方法参数_传递地址
平时都写int a、int b,其实数组也能作为参数 (如:int [ ] array)
请记住:任何数据类型都能作为方法的参数
我们使用一个数组作为方法参数的时候,其实是将名称当中保存的地址值传递进去,那么使用起来是非常简单的,比如a.length、a[2]
18_数组作为方法返回值_返回地址
边栏推荐
- Go uses the mencached cache
- Pioneer in Distributed Systems - Leslie Lambert
- The terminal connection tools, rolling Xshell
- ArrayList
- go : go-redis 基础操作
- 大飞机C919都用了哪些新材料?
- 预测人们对你的第一印象,“AI颜狗”的诞生
- Go: go - redis based operation
- DP5340国产替代CM5340立体声音频A/D转换器芯片
- Table with tens of millions of data, how to query the fastest?
猜你喜欢
Required request body is missing problem solving
云服务器零基础部署网站(保姆级教程)
New material under the plastic restriction order - polylactic acid (PLA)
export , export default,import完整用法
AI can identify race from X-rays, but no one knows why
ETL为什么经常变成ELT甚至LET?
Go语学习笔记 - gorm使用 - 数据库配置、表新增 Web框架Gin(七)
C#的访问修饰符,声明修饰符,关键字有哪些?扫盲篇
这个终端连接工具,碾压Xshell
export , export default, import complete usage
随机推荐
MySQL master-slave replication configuration construction, one step in place
理解和熟悉递归中的尝试
Table with tens of millions of data, how to query the fastest?
bin文件夹下的roslyn文件夹
Proof of distance calculation from space vertex to plane and its source code
Vue2进阶篇-编程式路由导航、缓存路由组件、路由的激活与失活
bean的生命周期
Ali Ermian: How many cluster solutions does Redis have?I answered 4
No, the Log4j vulnerability hasn't been fully fixed yet?
Calculate the inverse source of the matrix (using the adjoint matrix, a 3x3 matrix)
Electron日常学习笔记
Go: use gorm query record
Pioneer in Distributed Systems - Leslie Lambert
识别“数据陷阱”,发现数据的可疑之处
MySQL基础篇【命名规范】
RAID disk array
Derivative Operations on Vectors and Derivative Operations on Vector Cross and Dot Products
首届人工智能安全大赛正式启动
interface
MySQL off-topic [ORM thought analysis]