-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")
Benkerroum Mohamed
  • 1,867
  • 3
  • 13
  • 19

2 Answers2

2

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

This is the correct way:

if( ans1.equals("abc") )
aletede91
  • 1,137
  • 2
  • 16
  • 30
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