+ 1
How we can pass the array to method?
2 ответов
+ 2
By using the following example
public static void main (String args[] )
{
int[] array = {1, 2, 3, 4};
printArray(array) ;
}
void printArray(int[] arr) {
for(int i : arr)
System.out.println(i);
}
Here we pass the argument array to the method printArray
+ 1
simply pass the array name