title: How to match the chars of a string to the index of an array
body: <p>I have a string that consists of numbers, that I want to match to the contents of an array of words.</p>
  
  <p>Each char in the input string is matched to the position in the words array.</p>
  
  <p>If I print out the values of <code>i</code> and <code>j</code> before the <code>if</code> statement, they are correct, <code>0 and 0</code>, <code>3 and 3</code>, etc. The loop below however never enters the <code>if</code> statement. Please help me understand why.</p>
  
  <pre><code>String input = "0356";
  String[] words = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"};
  String[] result = new String[4];
  
  for (int i = 0; i &lt; input.length(); i++) {
      for (int j = 0; j &lt; words.length; j++) {
          if (Character.toString(input.charAt(i)) == Integer.toString(j)) {
              result[i] = words[j];
          }   
      }
  }
  </code></pre>
  
  <p>The result I am looking for:</p>
  
  <pre><code>result[] = {"zero","three","five","six"}
  </code></pre>