title: count occurrence of a character in a given string using one for loop with java
body: <p>This is the reference code:</p>
  
  <pre><code>    // Create an array of size 256 i.e. ASCII_SIZE
      int count[] = new int[MAX_CHAR];
  
      int len = str.length();
  
      // Initialize count array index
      for (int i = 0; i &lt; len; i++)
          count[str.charAt(i)]++;
  
      // Create an array of given String size
      char ch[] = new char[str.length()];
      for (int i = 0; i &lt; len; i++) {
          ch[i] = str.charAt(i);
          int find = 0;
          for (int j = 0; j &lt;= i; j++) {
  
              // If any matches found
              if (str.charAt(i) == ch[j])
                  find++;
          }
  
          if (find == 1)
              System.out.println("Number of Occurrence of " +
                      str.charAt(i) + " is:" + count[str.charAt(i)]);
      }
  </code></pre>
  
  <p>The output is supposed to resemble:</p>
  
  <blockquote>
    <p>Number of occurrence of 'x' is: 'times it occured'</p>
  </blockquote>
  
  <p>If the letter has occurred previously then only display the occurrence once.</p>
  
  <hr>
  
  <p>I get the logic using 2 for loops, although my teacher said its possible to execute this application using only 1 for loop.</p>
  
  <p>the issue i'm running into is:<Br>
  I'm able to find if the character has been already found only if they are beside each other. 
  <br>
  <br>
  How are you expected to check if all the previous character have been found without another for loop?</p>