title: How to count all the same characters in two strings
body: <p>Well here's my problem given two strings, for example:</p>
  
  <pre><code>String name1 = Joshuaa
  String name2 = Hazel
  </code></pre>
  
  <p>my output should be = 5</p>
  
  <p>since h = 2 ; a=3</p>
  
  <p>OR</p>
  
  <pre><code>String name1 = aaabbcd
  String name2 = aabbbefg
  </code></pre>
  
  <p>output = 10 ; since a=5 and b =5</p>
  
  <p>Here's my code so far but I'm getting the wrong output</p>
  
  <pre><code>name1 = name1.replaceAll("\\s","").toUpperCase();
  name2 = name2.replaceAll("\\s","").toUpperCase();
  
  nl1 = name1.length();
  nl2 = name2.length();
  
  char[] arrn1 = name1.toCharArray();
  char[] arrn2 = name2.toCharArray();
  
  for(i=0;i&lt;nl1;i++)
  {
    for(j=0;j&lt;nl2;j++)
    {
       if(arrn1[i]==arrn2[j])
       {
           count++;
       }
  
    }
  }
  </code></pre>