title: Why doesn't this .equals() work?
body: <p>I'm working in Eclipse (Android). In the following blocks, EmployeeInt and RestaurantInt are data types and query() opens a connection to the database and parses the results. When I print the query results, I get identical strings, but the boolean is still false. I've tried trimming the strings, but that didn't help.</p>
  
  <pre><code>public boolean verifyEmployee(String email, String password) {
      ArrayList&lt;EmployeeInt&gt; employeeEmailID = query("SELECT employeeID FROM employees WHERE emailAddress = \'"+email+"\'");
      ArrayList&lt;EmployeeInt&gt; employeePasswordID = query("SELECT employeeID FROM employees WHERE password = \'"+password+"\'");
      String stringEmployeeEmailID = employeeEmailID.toString();
      String stringEmployeePasswordID = employeePasswordID.toString();
  
      if(stringEmployeeEmailID.equals(stringEmployeePasswordID)) {
          return true;
      } else {
          return false;
      }
  }
  </code></pre>
  
  <p>Executing the above gives me false, while executing the following block (virtually identical) gives me true.</p>
  
  <pre><code>public boolean verifyRestaurant(String email, String password) {
      ArrayList&lt;RestaurantInt&gt; restaurantEmailID = query("SELECT restaurantID FROM restaurants WHERE emailAddress = \'"+email+"\'");
      ArrayList&lt;RestaurantInt&gt; restaurantPasswordID = query("SELECT restaurantID FROM restaurants WHERE password = \'"+password+"\'");
      String stringRestaurantEmailID = restaurantEmailID.toString();
      String stringRestaurantPasswordID = restaurantPasswordID.toString();
  
      if(stringRestaurantEmailID.equals(stringRestaurantPasswordID)) {
          return true;
      } else {
          return false;
      }
  }
  </code></pre>
  
  <p>Can anyone point out my mistake?</p>
  
  <p><em><strong>EDIT</em></strong></p>
  
  <p>I changed it to this and it worked:</p>
  
  <pre><code>public boolean verifyEmployee(String email, String password) {
      ArrayList&lt;EmployeeInt&gt; employeeEmailID = query("SELECT * FROM employees WHERE emailAddress = \'"+email+"\'");
      ArrayList&lt;EmployeeInt&gt; employeePasswordID = query("SELECT * FROM employees WHERE password = \'"+password+"\'");
      int intEmployeeEmailID = employeeEmailID.get(0).getID();
      int intEmployeePasswordID = employeePasswordID.get(0).getID();
  
      if(intEmployeeEmailID==intEmployeePasswordID) {
          return true;
      } else {
          return false;
      }
  }
  </code></pre>
  
  <p>I know I could also use return (condition), but I would like to add some messages if the login fails, something like:</p>
  
  <pre><code>System.err.println("email address and password do not correspond");
  </code></pre>
  
  <p>I'm not making an app to publish, it's merely for an assignment. Thanks for the help!</p>