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

    Oct 13, 2012 · You have a couple of basic misconceptions about Java: I want it to return the array without having to explicitly tell the console to print. 1) Java does not work that way. Nothing ever gets printed implicitly. (Java does not support an interactive interpreter with a "repl" loop ... like Python, Ruby, etc.) 2) The "main" doesn't "return" anything.

  2. 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 array of Object references is easy: public Object[] yourMethod() { Object[] array = new Object[10]; // Fill array return array; }

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

    Nov 25, 2019 · Returning an array from a Java method. 0. returning arrays in java? 0. Accessing array in a return method ...

  4. 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 (object(

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

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

  6. java - Returning elements from array - Stack Overflow

    May 20, 2011 · Returning an array in Java. 0. Returning a specific array element from a method. 0. returning value from ...

  7. Return two arrays in a method in Java - Stack Overflow

    Jun 14, 2011 · class User { String name; int[] values; // setters and getters for name, values } User[] doSomething() { User[] users = new User[10]; // fill the array return users; } Create a class representing the entire return value. This is good if you really do …

  8. Java Returning method which returns arraylist? - Stack Overflow

    Jul 27, 2012 · 1. If that class from which you want to call this method, is in the same package, then create an instance of this class and call the method.

  9. java - Possible to return a String array - Stack Overflow

    Oct 5, 2010 · Java - Returning multiple strings in an array. 0. How can I return an array from a method. Hot Network ...

  10. How to return an array from function using java - Stack Overflow

    Feb 21, 2018 · First, set the correct return type to return an array : public String[] add_show() Then, to print the result, I would suggest you to not print directly the result of the method, store them.