与java数组有关的源代码如何转换为对应字节码
6. 4: return
7.
8. public static void main(ng.String[]);
9. Code:
10. 0: iconst_3
11. 1: newarray int
12. 3: astore_1 13. 4: return
14. }
例子2:
[java] view plaincopy
1. public class TestArray {
2. public static void main(String[] args){
3. int [] arr1={1,2,3};
4. }
5. }
生成的字节码文件如下:
[java] 1. public class TestArray extends ng.Object{
2. public TestArray();
3. Code:
4. 0: aload_0
5. 1: invokespecial #8; //Method java/lang/Object."<init>":()V
6. 4: return
7.
8. public static void main(ng.String[]);
9. Code:
10. 0: iconst_3
11. 1: newarray int
12. 3: dup
13. 4: iconst_0
14. 5: iconst_1
15. 6: iastore //将int value 和索引index 弹出栈,赋值arr[index]=value;
16. 7: dup
17. 8: iconst_1
18. 9: iconst_2
19. 10: iastore
20. 11: dup
21. 12: iconst_2