Home >Java >javaTutorial >Can a java method return an array?
This time I want to talk about the use of arrays as method return values. A method can have multiple parameters, but it can only have one return value, not multiple return values. If you want a method to generate multiple data results for return, then you need an array as the return value.
Array as method return value
Array as method return value, returns the memory address of the array
public static void main(String[] args) { //调用方法,接收数组的返回值 //接收到的是数组的内存地址 int[] arr2 = getArray(); for (int i = 0; i <p><img src="https://img.php.cn/upload/image/919/382/497/1558516744817163.png" title="1558516744817163.png" alt="Can a java method return an array?"></p>
The above is the detailed content of Can a java method return an array?. For more information, please follow other related articles on the PHP Chinese website!