
Arrays 4.11
3. public static void main(String[] args) {
4. int[] arr = new int[]{10,20,30,40,50,60,70};
5. System.out.println(“ Given Array............”);
6. for(int i = 0; i < arr.length ; i++)
7. { System.out.print(arr[i] + “, “);}
8. System.out.println(“\nGiven Array Length :”+arr.length);
9. }
10. }
Output: Given Array............
10, 20, 30, 40, 50, 60, 70,
Given Array Length :7
Line No. 6: shows the usage of arr.length. Here arr.length returns the length of
array arr.
4.3.5 Passing Arrays as Arguments to Methods
Arrays can be passed as parameters to functions. To define a method with an array as a para-
meter use the following syntax: