Is it possible to return two or more values from a method to main in Java? If so, how it is possible and if not how can we do?
Specify multiple columns VLOOKUP can return a value from a single column, but we can easily return multiple column values with Power Query. To do so, just click the Expand icon on the right side of the Detail column header, or the Transform > Structured Column > Expand command.
The VLOOKUP Function always returns the first match. In order to return duplicate values (or the nth match) we need: A new unique identifier to differentiate all duplicate values. A helper column containing a list of unique IDs that will serve as the new lookup column (first column) of the table array.
You can return an object of a Class in Java.
If you are returning more than 1 value that are related, then it makes sense to encapsulate them into a class and then return an object of that class.
If you want to return unrelated values, then you can use Java's built-in container classes like Map, List, Set etc. Check the java.util package's JavaDoc for more details.
You can do something like this:
public class Example { public String name; public String location; public String[] getExample() { String ar[] = new String[2]; ar[0]= name; ar[1] = location; return ar; //returning two values at once } }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With