title: Every combination of characters from dynamic list
body: <p>I am stuck with a logic. I have a free text dropdown where users are free to enter up to 5 characters. Now every character has unicode accent characters associated to it. I generate unicode characters for the list associated for the characters. Now I want to generate all possible combinations with the characters from the list. I am a bit stuck since the list is generated dynamically. How do I possibly get to know which list should be iterated first? Below is my code.</p>
  <pre><code>//example String key=&quot;za&quot;;
  if (key!=null) {
      List&lt;Character&gt; characList = key.chars()
                                      .mapToObj(c -&gt; (char) c)
                                      .collect(Collectors.toList());//[z, a]
      List&lt;List&lt;String&gt;&gt; mainList = new ArrayList&lt;List&lt;String&gt;&gt;();
      for (Character characterObj:characList) {
          List&lt;String&gt; subList = new ArrayList&lt;String&gt;();
          Collection&lt;String&gt; charColl = unicodeMap.getCollection(characterObj.toString());
          subList = new ArrayList(charColl);//first iteration we get [ż, ź, ž] second iteration we get [à, á, â, ã, ä, å, ą, ă, ā]
          mainList.add(subList);//[[ż, ź, ž], [à, á, â, ã, ä, å, ą, ă, ā]]
      }
  }
  </code></pre>
  <p>Now i want to generate combination of <code>String</code> from <code>[[ż, ź, ž], [à, á, â, ã, ä, å, ą, ă, ā]]</code>.
  The <code>String</code> could have been azstu,etc. How do i iterate so that it will take care of all combinations from the associations of entered <code>String</code>. Please advise.</p>
  <p>Desired output from the example String:-</p>
  <pre><code>żà
  żá
  żâ
  żã
  żä
  żå
  żą
  żă
  żā
  .
  .
  .
  </code></pre>