-4

if condition doesn't validate the value inside string mentioned below.

  //getting input box value
   newText = input.getText().toString();

  //using if condition newText got value "a"

    if (newText=="a")
    {
    //do something
    }

but the above if condition doesn't work i check string got right value which is a.

thanks in advance

1 Answers1

1

In java you should use equals method to compare the values of strings:

if ("a".equals(newText)) {
   //do something
}

To compare the references you can use ==. For more information check this: https://stackoverflow.com/a/513839/3225458

Community
  • 1
  • 1
romtsn
  • 11,704
  • 2
  • 31
  • 49