About 369,000 results
Open links in new tab
  1. How to Return an Array in Java? - GeeksforGeeks

    Jun 29, 2022 · The java.lang.reflect.Array.getShort() is an in-built method of Array class in Java and is used to return the element present at a given index from the specified Array as a short. Syntax: Array.getShort(Object []array,int index) Parameters: array: The object array whose index is to be returned. inde

  2. How to store an array returned by a method in Java

    Feb 24, 2017 · public int[] method() { int z[] = {1,2,3,5}; return z; } The above method does not return an array par se, instead it returns a reference to the array. In the calling function you can collect this return value in another reference like: int []copy = method(); After this copy will also refer to the same array that z was refering to before.

  3. How to Return an Array in Java? (from a Method) - FavTutor

    Sep 26, 2024 · Learn how to return an array in java in this article with code. We also mentioned how to pass and return an array in java from a method.

  4. Return an Array from a Method in Java - Online Tutorials Library

    Learn how to return an array from a method in Java with this comprehensive guide. Understand the syntax and examples for effective implementation.

  5. How to return an array in Java? - Tpoint Tech

    In Java, there are several ways to return an array from a method, each offering its own advantages and use cases. These methods can be broadly categorized into static arrays, dynamically created arrays, subarrays, and arrays generated using Java Streams.

  6. How to Return an Array in Java? - JavaBeat

    Nov 30, 2023 · Use the “return” keyword before the array name to return a single or multi-dimensional array in Java. The return of an array enhances the reusability and allows users to divide the code into multiple functions.

  7. How To Return An Array In Java? A Detailed Guide With …

    Returning an array in Java involves creating it in a method, adding values if needed, and using return to pass it back to the calling code for use.

  8. How to Return an Array in Java: An In-Depth Guide and Best …

    Dec 27, 2023 · Key Takeaways and Best Practices for Returning Arrays in Java. We‘ve explored several techniques for returning array references in Java, including: Returning variable references – For passing back a reference to an existing array computed within a method. Returning literals – Useful when you want to construct a new array each method call.

  9. How To Pass / Return An Array In Java - Software Testing Help

    Apr 1, 2025 · In this tutorial, we will discuss how to pass arrays as an argument to a method and return the array from the method. Arrays can be passed to other methods just like how you pass primitive data type’s arguments. To pass an array as an argument to a method, you just have to pass the name of the array without square brackets.

  10. How to Return Array in Java - Scientech Easy

    Feb 14, 2025 · Learn how to return an array in java with example, syntax for returning one dimensional array from a method, 2D array from a method in java

  11. Some results have been removed
Refresh