title: Find number of repetitions of characters in a given Word
body: <p>So I was developing an algorithm to count the number of repetitions of each character in a given word. I am using a <code>HashMap</code> and I add each unique character to the <code>HashMap</code> as the key and the value is the number of repetitions. I would like to know what the run time of my solution is and if there is a more efficient way to solve the problem. </p>
  
  <p>Here is the code : </p>
  
  <pre><code>public static void getCount(String name){
          public HashMap&lt;String, Integer&gt; names = new HashMap&lt;String, Integer&gt;() ;
          for(int i =0; i&lt;name.length(); i++){
  
              if(names.containsKey(name.substring(i, i+1))){
                  names.put(name.substring(i, i+1), names.get(name.substring(i, i+1)) +1);
              }
              else{
                  names.put(name.substring(i, i+1), 1);
              }
          }
  
          Set&lt;String&gt; a = names.keySet();
          Iterator i = a.iterator();
  
          while(i.hasNext()){
              String t = (String) i.next();
              System.out.println(t + " Ocurred " + names.get(t) + " times");
          }
      }
  </code></pre>