Click to enter _ more _java thousand ask
1. How the array is passed
In Java, we can pass an array as an argument to a method, in a way that is consistent with passing the basic type parameter.
Learn what an array looks here: What is an array in Java
Understanding loop Arrays Here's how: how to iterate through an array
Example:
publicstaticvoidprintArray(int[] array) { for (int0; i < array.length; i++) { System.out" "); }}
It can be called by passing an array. For example:
printArray(newint[]{312642});
The results are as follows:
3,1,2,6,4,2
2. How the method returns an array
Method can also return an array.
Example:
reverselist) { result = new int[list.length]; for0result.length1list.length; i++, j--) { resultlist[i]; } returnresult;}
The method returns an array, which is the inverse of another array.
Java thousands ask _06 data structure (013) _ How the array is passed