Home >Java >javaTutorial >Can a java method return an array?

Can a java method return an array?

(*-*)浩
(*-*)浩Original
2019-05-22 17:22:2711391browse

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.

Can a java method return an array?

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn