title: Comparing Two strings in Java (If/Else statement) -- Android App
body: <p>I am working on a login page in an Android App. </p>
  
  <p>As you know, the app must check if the username and password are valid, and then grant the user access to the application.</p>
  
  <p>I have used the following code:</p>
  
  <p>... </p>
  
  <pre><code>EditText un = (EditText) findViewById(R.id.username1);
  
  EditText pw = (EditText) findViewById(R.id.password1);
  
  String u = un.getText().toString();
  
  String p = pw.getText().toString();
  
  
  String myUser = "user1";
  
  String myPass = "pass1";
  
  //////// Now on the click of the Login Button:
  
  
  public void onClickL (View view){
  
  if ( (u == myUser) &amp;&amp; (p == myPass)) /////// move to a new activity
  
  else ///////Display a warning message: Try again
  
  }
  </code></pre>
  
  <p>I entered the correct strings in both editText fields, however i always get the warning message.
  I don't understand what is wrong with it.</p>
  
  <p>Please help :) </p>