-1

In my Android app, I enter the string "el". In AsyncTask, I do some operations if I enter exactly "el". In this code :

protected class AsyncTranslator extends AsyncTask<String, JSONObject, String> {
    @Override
    protected String doInBackground(String... params) {

        String mymeaning = null;
        RestAPI api = new RestAPI();
        try {

            //if(params[0] == "el") this doesn't work
            //if(params[0].trim() == "el") this doesn't work either
          //  if(params[0].substring(0, 1).trim() == "e" && params[0].substring(params[0].length() -1).trim() == "l") this doesn't work either
         if(params[0].contains("el")) //this works but it works for other elements containing "el" as well

What kind of if should I write so that it shall work only on string "el". Thanks.

jason
  • 6,962
  • 36
  • 117
  • 198

1 Answers1

2

Try:

if ("el".equals(params[0])) {
    // do your stuff
}
FlyingPumba
  • 1,015
  • 2
  • 15
  • 37