title: Counting the occurrence of alphanumeric characters and printing them graphically
body: <p>I have a string, and I want to count the occurrence of all letters and numbers and want to create a graph so I can see the occurrence graphically. </p>
  
  <p>So for example: </p>
  
  <pre><code>String sentence = "ABC ABC ABC 123"
  
  A (3) * * *
  B (3) * * *
  C (3) * * *
  D
  .
  .
  </code></pre>
  
  <p>My way of thinking: </p>
  
  <ol>
  <li>Count all numbers and letters in the string</li>
  <li>Print all asterisks times this number (unfortunately I can't multiply a String with an int in Java)</li>
  </ol>
  
  <p>I think there are two ways of counting the characters. I can either use the <code>charAt()</code> method or <code>toCharArray()</code> and loop through the string or array and count the letters. </p>
  
  <p>For example: </p>
  
  <pre><code>aCounter = 0;
  bCounter = 0;
  char ch = sentence.charAt(i);
  
  for (i = 0; i &lt; sentence.length(); ++i) {
      if (ch == 'a') {
          aCounter++;
      }
      if (ch == 'b') {
          bCounter++;
      }
  }
  </code></pre>
  
  <p>However, I have multiple problems with this approach: </p>
  
  <ul>
  <li>I would have a to make a lot of counter variables - <code>aCounter</code> through <code>zCounter</code> plus <code>0counter</code> through <code>9counter</code></li>
  <li>I would have to make another for loop to print the asterisks!</li>
  </ul>
  
  <p>I'm not asking for an set answer here, I'm just looking for some good directions, because I'm stuck.</p>