I'm trying to make an app where the user enters a word into an EditText box. Then, they enter something into another box and it checks to see if they are the same word. Here's the code that I used:
String word = textfield1.getText().toString(); String answer = textfield2.getText().toString(); textfield2.setText(textfield2.getText().toString()); if(word == answer){ Toast.makeText(getApplicationContext(), "correct", Toast.LENGTH_LONG).show(); }else Toast.makeText(getApplicationContext(), "incorrect", Toast.LENGTH_LONG).show(); } However, it always says that the two strings aren't the same even if they are. Is there a way to fix this?
==,if you want compare the two string useequalsandequalignorecaselikethat functionlity.