-1
     public void clickmea(View view)
       {
          EditText ed1 = (EditText) findViewById(R.id.editText4);      
          EditText ed2 = (EditText) findViewById(R.id.editText5);       
          String s1=ed1.getText().toString();      
          String s2=ed2.getText().toString();    
          if ((s1 == "abc") && (s2 == "abc"))      
              {     
                 Log.i("msg","successful");        
              }      
          else     
              {          
                 Log.i("msg","unsuccessful");   
              }        
       }

when I run above code it displays unsuccessful msg in the log even if I type abc in both text boxes.

Faysal Ahmed
  • 7,501
  • 5
  • 28
  • 50

1 Answers1

-1

Try this

 if (s1.equals("abc") && s2.equals("abc"))      
     {     
        Log.i("msg","successful");        
     }else     
        {          
         Log.i("msg","unsuccessful");   
        } 
Faysal Ahmed
  • 7,501
  • 5
  • 28
  • 50