Files
javaSE251223/day05/src/com/inmind/Demo05.java

22 lines
558 B
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package com.inmind;
/*
数组作为方法参数_传递地址
*/
public class Demo05 {
public static void main(String[] args) {
//定义int型数组
int[] arr = {1,2,3};
foreachArray(arr);
//定义int型数组
int[] arr1 = {4,5,6};
foreachArray(arr1);
}
//我要定义一个方法动态接收int数组对该数组进行遍历打印
public static void foreachArray(int[] array){
for (int i = 0; i < array.length; i++) {
System.out.println(array[i]);
}
}
}