本地new int[]的处理
来源:互联网 发布:ubuntu mount ntfs 编辑:程序博客网 时间:2024/05/18 05:53
本文主要展示Java代码函数中定义的数组初始化的处理。为了简单起见,我们使用如下的代码:
public static void main(String[] argv) { int[] arr = new int[]{1, 2, 3, 4}; return; }
编译后的代码如下:
Code: stack=4, locals=2, args_size=1 0: iconst_4 1: newarray int 3: dup 4: iconst_0 5: iconst_1 6: iastore 7: dup 8: iconst_1 9: iconst_2 10: iastore 11: dup 12: iconst_2 13: iconst_3 14: iastore 15: dup 16: iconst_3 17: iconst_4 18: iastore 19: astore_1 20: return
指令0-1初始化一个长度为4的int数组。
指令3在操作栈中复制数组指针。
指令4-6则将数组的0号元素赋值1。同样的指令7-10,11-14,15-18分别给数组的1号,2号,3号元素赋值1,2,3。
19指令把数组arr引用存到本地变量数组1号slot。
综上,本地数组初始化时编译器在一开始时就确定元素的个数。然后通过iastore进行赋值
0 0
- 本地new int[]的处理
- c++学习之new int()和new int[]的区别
- c++学习之new int()和new int[]的区别
- c++学习之new int()和new int[]的区别
- int a 和int*a = new int 的区别
- int *p1 = new int[10]; int *p2 = new int[10](); 的区别
- int* pInt = new int(5)和int* pInt = new int[5]的区别
- int *p = new int(5); 和 int *p = new int[5]的区别
- int* p = new int[5](); 与 int* q = new int[5]; 的区别
- new StringBuffer(int n)的陷阱
- new StringBuffer(int n)的陷阱
- C++中针对int *p = new int(5) 与 int *p = new int[5]的区别
- java中,从空间的角度比较 new int[2][100] 与 new int[100][2]
- 由int i和int i=new int()想到的
- 关于 new int() 和 new int[]
- C++new失败的处理
- C++new失败的处理
- C++ new 失败的处理
- SharedPreferences
- 终于赶在软件测试部前头解决Access数据库压缩的问题
- leetcode第一刷_Distinct Subsequences
- 5月7号-坚持
- POJ-1182-食物链 解题报告
- 本地new int[]的处理
- 【Android】自定义控件——仿天猫Indicator
- sqli-labs从零开始学习日记 开心的第一步
- 克33+9爆利拉德阿德32分 马刺24分大胜开拓者
- 关于Date Time Picter的初始化和保存
- coco2dx 3.0 在安卓上按返回键没有作用
- 黑马程序员——java基础之环境变量设置
- 游标的简单例子
- HashMap实现原理分析