title: equalsIgnoreCase method isn't working with JOptionPane (or Scanner) input
body: <pre><code>    // ask user to enter name of state capital
      String answer = JOptionPane.showInputDialog("What is the capital of " + 
              question + "?");
  
      // verify name of state capital is in citiesarray
      boolean isPresent = false; int stateNum = 0;
      System.out.println(answer); // troubleshooting line
      for (int i = 0; i &lt;= 49; i++) {
          String city = citiesarray[i];
          isPresent = answer.equalsIgnoreCase(city);
          System.out.println(city); // troubleshooting line
          System.out.println(answer.compareTo(city)); // troubleshooting line
          System.out.println(isPresent); // troubleshooting line
          if (isPresent == true) {
              stateNum = i; break;
          }
      }
      if (isPresent == false) {
          JOptionPane.showMessageDialog(null, "That is incorrect. Please try another round.");
          return;
      }
  </code></pre>
  
  <p>Whenever I run this code, I end up with all false booleans for every iteration of the loop, no matter what capital I enter. It seems like the <code>compareTo</code> output for whatever city that should return true for <code>equalsIgnoreCase</code> is always -1, but I don't know how to use that to identify and solve my problem.</p>
  
  <p>I've tried a couple of different things and found that with Scanner, it seemed to work as long as answer didn't contain a space, but that doesn't seem to matter with <code>JOptionPane</code>, and regardless, I need this to work no matter what the capital of the state is.</p>