title: Trie permutations not found
body: <p>I'm running into a problem while using a Trie in Java for an anagram solver.  The following code is for Android and does not give me any permutation results for the letters that are given and passed in.  However, if I implement the same code in a Java desktop application, it returns the correct results for me.  I'm pretty sure it's something simple that's going wrong, I just can't seem to find it.  </p>
  
  <p>Code for Desktop version:</p>
  
  <pre><code>static String myWord;
      static String myLetters = "";
      static char[] myChars;
      static TrieNode myNode = new TrieNode();
      static TrieNode currentNode;
      static ArrayList&lt;String&gt; availableWords = new ArrayList&lt;String&gt;();
  
      public static void main(String[] args) {
  
          Scanner s = new Scanner(System.in);
          myLetters = s.next();
  
          readWords();
          getPermutations();
      }
      public static void getPermutations(){
          currentNode = myNode;
          for(int x = 0; x &lt; myLetters.length(); x++){
              if(currentNode.children[myLetters.charAt(x) - 'a'] != null){
                  availableWords.addAll(currentNode.getWords());
                  currentNode = currentNode.children[myLetters.charAt(x) - 'a'];
                  System.out.println("x: " + x + " " + currentNode.getWords() + "" + myLetters.charAt(x));
              }
          }   
          System.out.println(availableWords);
      }
  
  Desktop Output:
  aelpp  //(user input from scanner)
  x: 0 []a
  x: 1 [ae]e
  x: 2 [ale, lea]l
  x: 3 [leap, pale, peal, plea]p
  x: 4 [appel, apple, pepla]p
  [ae, ale, lea, leap, pale, peal, plea] 
  </code></pre>
  
  <p>Android code:</p>
  
  <pre><code>static String myWord;
      static char[] myChars;
      static TrieNode myNode = new TrieNode();
      static TrieNode currentNode;
      static ArrayList&lt;String&gt; availableWords = new ArrayList&lt;String&gt;();
  
      public static void getPermutations(String passedInLetters){
          currentNode = myNode;
          Log.i("TRIE:" , passedInLetters);
          for(int x = 0; x &lt; passedInLetters.length(); x++){
              if(currentNode.children[passedInLetters.charAt(x) - 'a'] != null){
                  availableWords.addAll(currentNode.getWords());
                  Log.i("TRIE:" , "x: " + x + " " + currentNode.getWords());
                  currentNode = currentNode.children[passedInLetters.charAt(x) - 'a'];
              }
          }
          Log.i("TRIE:", availableWords.toString());
      }
  </code></pre>
  
  <p>Android Log Output:</p>
  
  <pre><code>03-15 22:45:11.670: I/TRIE:(4286): aelpp
  03-15 22:45:11.670: I/TRIE:(4286): x: 0 []
  03-15 22:45:11.670: I/TRIE:(4286): x: 1 []
  03-15 22:45:11.670: I/TRIE:(4286): x: 2 []
  03-15 22:45:11.670: I/TRIE:(4286): x: 3 []
  03-15 22:45:11.670: I/TRIE:(4286): x: 4 []
  03-15 22:45:11.670: I/TRIE:(4286): []
  </code></pre>
  
  <p>If needed, here are the full classes:</p>
  
  <p>Desktop: <a href="http://pastie.org/3604515" rel="nofollow noreferrer">http://pastie.org/3604515</a>
  Android: <a href="http://pastie.org/3604513" rel="nofollow noreferrer">http://pastie.org/3604513</a></p>
  
  <p>I have been studying this post among some of my other sources: <a href="https://stackoverflow.com/questions/9138239/java-string-permutations-and-combinations">java string permutations and combinations lookup</a></p>
  
  <p>Thanks!</p>
  
  <p>EDIT:  </p>
  
  <p>These lines needed switched inside the if statement:</p>
  
  <pre><code>currentNode = currentNode.children[passedInLetters.charAt(x) - 'a'];
                  availableWords.addAll(currentNode.getWords());
  </code></pre>