About 9,780,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:

  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. java - creating and returning an array from a method - Stack Overflow

    Apr 4, 2010 · Declare the return type to be two dimensional array (int[][]), create the array in your method and return that. int[][] myArray = new int[3][3]; // Populate array. return myArray; See similar questions with these tags.

  5. java return array in method - Stack Overflow

    Sep 11, 2015 · If you want to return an array that contains the odd index elements from the original array. you should check index%2!=0 instead of checking array value of that index. try this

  6. 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.

  7. 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

  8. 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.

  9. Passing, Returning An Array To, From a Method in Java Programming

    In this tutorial, you will learn how to pass / return an array to / from a method in java programming. You will learn how to pass an array to a method and work with in inthe method and then how you can return an array from the method using the return statement in …

  10. Java Arrays - How to return array in java from method?

    Nov 22, 2021 · A quick guide on how to return arrays in java from methods for primitive, objects and multidimensional arrays.

Refresh