title: How to compare two characters in Java in if conditon?
body: <p>How can I compare two characters in Java?</p>
  
  <pre><code>while(s1.hasNext()) {
      if(a[j].equals('x')
          x++;
      if(a[j].equals('y')
          y++;
  }
  </code></pre>
  
  <p>I have repeated the loop using for loop for n times and a[j] is an array. I am getting the error at if condition inside the while loop. Could anyone please explain me about the error?</p>