Test5.java 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package com.sf;
  2. public class Test5 {
  3. public static void main(String[] args) {
  4. /** 动态初始化
  5. * 数组存储的元素的数据类型[] 数组名字 = new 数组存储的元素的数据类型[长度];
  6. * 或
  7. * 数组存储的数据类型[] 数组名字;
  8. * 数组名字 = new 数组存储的数据类型[长度];
  9. */
  10. int[] aa = new int[3];
  11. int[] bb;
  12. bb = new int[4];
  13. // for (int i =0;i<aa.length;i++ ){
  14. // aa[i]=1;
  15. // }
  16. aa[0]=1;
  17. aa[1]=2;
  18. aa[2]=3;
  19. for (int i =0;i<aa.length;i++ ){
  20. System.out.println(aa[i]);
  21. }
  22. /*
  23. 基本数据类型
  24. */
  25. int[] vv = new int[5];
  26. for (int i =0;i<vv.length;i++){
  27. System.out.println(vv[i]);
  28. }
  29. /**
  30. * 包装类
  31. */
  32. Integer[] mm = new Integer[5];
  33. for (int i =0;i<mm.length;i++){
  34. System.out.println(mm[i]);
  35. }
  36. }
  37. }