I have a Java method which returns an array of doubles. I would then like to store these values in individual variables in the calling function. Is there an elegant way of doing this in Java.
I could write it as this:
double[] returnValues = calculateSomeDoubles();
double firstVar = returnValues[0];
double secondVar = returnValues[1];
I was just wondering if there was some way of compressing this down to a single line? Something like:
(firstVar, secondVar) = calculateSomeDoubles();
This type of thing is quite easy when scripting, but the stronger typing of Java means it probably isn't possible.