本帖最后由 嘿~~ 于 2014-4-13 10:50 编辑
int[]类型变量arr作为局部变量
- class FieldDemo
- {
-
- public static void main(String[] args)
- {
- int[] arr={3,6,4,23,67,24,65,29};
- FieldDemo.printArr(arr);
- }
-
- public static void printArr(int[] arr)
- {
- System.out.print("[");
- for(int x=0;x<arr.length;x++)
- {
- if(x!=arr.length-1)
- System.out.print(arr+",");
- else
- System.out.print(arr+"]");
- }
- }
- }
复制代码 int[]类型变量arr作为成员变量- class FieldDemo
- {
- int[] arr={3,6,4,23,67,24,65,29};
- public static void main(String[] args)
- {
-
- FieldDemo.printArr();
- }
-
- public static void printArr()
- {
- System.out.print("[");
- for(int x=0;x<arr.length;x++)
- {
- if(x!=arr.length-1)
- System.out.print(arr+",");
- else
- System.out.print(arr+"]");
- }
- }
- }
复制代码 |
|