title: Array of Strings in Java
body: <p>I'm working on an algorithm to find all paths between two nodes in a graph. That's it, I was able to encode all paths in an Array of Strings as follows:</p>
  
  <pre><code>String []paths = new String[50];
  </code></pre>
  
  <p><em>Note: I'm using an array of strings to store the paths, but I can store them in any other data structure when necessary.</em></p>
  
  <p>Sample of the data in my array would be something like the table below, note that the letters are my data the hyphens used for visualization only:</p>
  
  <pre><code> -----------
  | A | B | C |
   -----------
  | D | E |   |
   -----------
  </code></pre>
  
  <p>All I need is to process the above array, and output all the combinations as:</p>
  
  <pre><code>ABC
  
  AEC
  
  DBC
  
  DEC
  </code></pre>
  
  <p>I tried to solve this problem using the iterative approach "loops", but I failed. I think we might to do this with recursion, but I'm not sure how to do that.
  Also, I'm not aware if there is any data structure that deals with this problem. Something better to store the paths rather than an array of strings?</p>
  
  <p>Anyway, here is what I'm working on with loops:</p>
  
  <pre><code>String []temp = new String[100];
  for( r=0; r&lt;paths.length ;r++ )
     for( c=0; c&lt;paths[r].length() ;c++ )
        for( j=c+1; j&lt;paths[r].length() ;j+1 )
           temp[r] += paths[j];
  </code></pre>