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

    Oct 13, 2012 · 3) If (hypothetically) you did want your "main" method to return something, and you altered the declaration to allow that, then you still would need to use a return statement to tell it …

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

    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 do I return an array of objects in java? - Stack Overflow

    Aug 24, 2012 · Well, you can only actually return an array of references to objects - no expressions in Java actually evaluate to objects themselves. Having said that, returning an …

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

    In contrast, Component.getLocation(), Component.getSize() and Component.getBounds() return copies, because Point, Dimension and Rectangle are mutable. The general design pattern is …

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

  6. java return array in method - Stack Overflow

    Sep 11, 2015 · Issue with your code: you can not define method inside another method. If you want to return an array that contains the odd index elements from the original array. you …

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

    In other words, this method will return an array of type Object. There is no way to cast an Object[] to an Integer[] because they are not the same type. If you want your method to be able to …

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

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

    if someone would like to know how to return String[] array: java code. private native String[] data(); native export. JNIEXPORT jobjectArray JNICALL Java_example_data() (JNIEnv *, jobject); …

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

    I'm aware that arrays are objects and in java objects are transfered by reference which could cause aliasing so objects should be returned with in this form to not cause aliasing: return new …

Refresh