About 232,000 results
Open links in new tab
  1. Returning Arrays in Java - Stack Overflow

    Oct 13, 2012 · The numbers method returns the int array, but you're doing nothing with the returned array. What do you expect, a magical force that will print the array in the console?

  2. Returning an array without assign to a variable - Stack Overflow

    Nov 25, 2019 · You still need to create the array, even if you do not assign it to a variable. Try this: public int[] getData() { return new int[] {a,b,c,d}; } Your code sample did not work because …

  3. How to return an array in one line in Java? - Stack Overflow

    No matter how you try to shorten your code, it doesn't change the fact that when the call to getCoord () returns, it simply returns a reference to the array, not a copy of the contents of the …

  4. How do I return an array of objects in java? - Stack Overflow

    Aug 24, 2012 · Returning an object array has been explained above, but in most cases you don't need to. Simply pass your object array to the method, modify and it will reflect from the called …

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

    Feb 24, 2017 · 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. …

  6. java return array in method - Stack Overflow

    Sep 11, 2015 · I'm doing my first steps in java, so my question is simple - I have an array with 8 integers and I want to return an array that contains the odd index elements from the original …

  7. How to properly return generic array in Java generic method?

    To summarize here, type erasure removes the type, so if you want to return a generic array of a specific type, you will need to pass in that type.

  8. How to return an array from JNI to Java? - Stack Overflow

    I am attempting to use the android NDK. Is there a way to return an array (in my case an int[]) created in JNI to Java? If so, please provide a quick example of the JNI function that would do …

  9. java - Returning an empty array - Stack Overflow

    You can return empty array by following two ways: If you want to return array of int then Using {}: int arr[] = {}; return arr; Using new int[0]: int arr[] = new int[0]; return arr; Same way you can …

  10. Java - how to return in a method multidimensional array without ...

    Do you want to return a copy of newArr? see the following: copy a 2d array in java If you don't need a copy - just return newArr.

Refresh