-1

this is what I tried doing:

 EditText text_ans1 = (EditText)findViewById(R.id.ans_one);
 String ans1 = text_ans1.getText().toString();
 if(ans1=="abc")
B.M
  • 1,752
  • 3
  • 13
  • 18

2 Answers2

2

You can't compare strings with == in Java.

This is the correct way:

if( ans1.equals("abc") )
aletede91
  • 1,045
  • 1
  • 14
  • 29
2

The == operator is comparing references, that's not what you want. Like @aletede91 said you have to use the equals method to compare values

SamyB
  • 235
  • 1
  • 9