Such as in PHP:
<?php
$a = 'hello';
$$a = 'world';
echo $hello;
// Prints out "world"
?>
I need to create an unknown number of HashMaps on the fly (which are each placed into an arraylist). Please say if there's an easier or more Java-centric way. Thanks.
$a = "hello";, then$$a="world";is equivalent to$hello="world";, it used the string as a variable name... this actually can be extremely powerful when used well, thanks to it, it made class builds for json encoding purposes a walk in the park, literally took 1 line to do with it; example:function addParam($key,$val){$this->${$key} = $val }. a new variable under the class gets created out of nothing at runtime.