What is the equivalent of PHP's
$matches = array('12', 'watt');
list($value, $unit) = $matches;
Due to java always passes primitives by value and does not have native support of perl style lists I am afraid there is no way to do what you need.
You can write method
list and pass there variables
unit. You can changes values of these variables. But the changes will be visible into the
list method only. The original values of
unit will be the same as before the call.
The java-style solution for this problem is creating custom class (even inner class it does not have any sense in other contexts). Then create method that parses your string (using regex) and creates instance of the class.