title: "The method charAt(int) is undefined for the type Stringchar" error on using charAt method
body: <pre><code>package Collections;
  
  import java.util.HashSet;
  import java.util.Iterator;
  import java.util.LinkedHashSet;
  
  public class Stringchar {
  
      public static void main(String[] args) {
  
          int count =0;
          String s = "mmamma";
  
          //System.out.println(s.length());
  
          LinkedHashSet&lt;Character&gt; ch = new LinkedHashSet&lt;Character&gt;(); 
          for (int i=0; i&lt;s.length(); i++){
              ch.add(s.charAt(i));
          }
  
          Iterator&lt;Character&gt; iterator = ch.iterator();
          while(iterator.hasNext()){
  
              Character st = (Character) iterator.next();
              for (int k=0; k&lt;s.length() ; k++){
                  if(charAt(k)==  st){ // Why this charAt method is not working?   
                      count = count+1;
                  }
  
                  if(count&gt;1) {
                      System.out.println("Occurance of "+ st + "is" + count);
                  }
              }                           
          }           
      }
  }
  </code></pre>
  
  <p>I am new to coding so I might be silly in asking this question. I have written a code where I am trying to print the occurrences and the number of the same of one character in a string using sets however I am facing some issues in doing so. Request you to help.</p>