Home > Java > javaTutorial > body text

Can a java method return an array?

(*-*)浩
Release: 2019-05-22 20:45:55
Original
11340 people have browsed it

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>
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template