[java] Comparing strings in Java

Im trying to compare the values of two edittext boxes. What i would like is to just compare passw1 = passw2. As my code is now comparing two strings i have entered as i could not get to compare them.

 final EditText passw1= (EditText) findViewById(R.id.passw1);
 final EditText passw2= (EditText) findViewById(R.id.passw2);
 Button buttoks = (Button) findViewById(R.id.Ok);
      buttoks.setOnClickListener(new OnClickListener() {    

    public void onClick(View v) {       

     if (passw1.toString().equalsIgnoreCase("1234") && passw2.toString().equalsIgnoreCase("1234")){
      Toast.makeText(getApplication(),"Username and password match", Toast.LENGTH_SHORT).show();
    else {
        Toast.makeText(getApplication(),"Username and password doesn't match", Toast.LENGTH_SHORT).show();
     }   }); 

This question is related to java android string

The answer is

Using the == operator will compare the references to the strings not the string themselves.

Ok, you have to toString() the Editable. I loaded up some of the code I had before that dealt with this situation.

String passwd1Text = passw1.getText().toString();
String passwd2Text = passw2.getText().toString();

if (passwd1Text.equals(passwd2Text))

Similar questions with java tag:

Similar questions with android tag:

Similar questions with string tag: