title: JAVA - reading character with SCANNER
body: <p>Here is the problem that I'm working on.</p>
  
  <p>We have to ask the user to enter a string, and then enter a character (any character would be fine). And then count the number of times that character appears in the scanner.</p>
  
  <p>I cannot figure out how to add character to scanner. We haven't done arrays yet so I don't wanna go there but this is what I have done so far:</p>
  
  <pre><code>import java.util.Scanner;
  
  public class Counter {
  
     public static void main (String args[]){
  
          String a;
          char b;
          int count;
          int i;
  
  
          Scanner s = new Scanner (System.in);
  
  
          System.out.println("Enter a string");
  
          a = s.nextLine();
  
          System.out.println("Enter a character");
  
          b = s.next().charAt(0);
  
          count = 0;
          for (i = 0; i &lt;= a.length(); i++){
  
              if (b == s.next().charAt(b)){
  
                  count += 1;
  
          System.out.println(" Number of times the character appears in the string is " + count);
  
                  else if{
  
                      System.out.println("The character appears 0 times in this string");
              }
  
  
              }
  
          }
  </code></pre>
  
  <p>I know this is incorrect but I cannot figure this out right now. </p>
  
  <p>Any help would be highly appreciated. </p>