+ 1

How we can pass the array to method?

6th Apr 2016, 3:36 PM
Ismail
Ismail - avatar
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
23rd Jun 2016, 5:37 PM
Mwakima Matano
Mwakima Matano - avatar
+ 1
simply pass the array name
5th Jul 2016, 9:08 PM
Akash Saha
Akash Saha - avatar