How to let java to substitute chars in string and make it executable
<p>I haven't found any information if it's even possible. I want to use method or some other way to return string and put it into for loop so that when loop executes it can put loop parameters into returned string and compose new string. As you probably guess I want to insert keyStr into hashmap but with substitutions as is done in dynamicKeyStr. dynamicKeyStr solution is great but it's structure may change over time that's why I cannot write it statically.</p>

<p>Sometimes it's:</p>

<pre><code>dynamicKeyStr = array[i][1]+"-"+array[i][3]+"-"+array[i][8];
</code></pre>

<p>Another time it's:</p>

<pre><code>dynamicKeyStr = array[i][13]+"-"+array[i][5];
</code></pre>

<p>and so on.</p>

<pre><code>public void dynamicForLoop() {
    for (int i = 0; i &lt; array.length; i++) {
            String dynamicKeyStr = array[i][1]+"-"+array[i][3]+"-"+array[i][8];
            //String KeyStr = "array[i][1]+\"-\"+array[i][3]+\"-\"+array[i][8]";
            hashSet.add(dynamicKeyStr);
    }
}
</code></pre>
