title: How to compare input text with string array in android studio?
body: <p>I am new to app development and I have a problem with coding in android studio. I want to compare an input text with a string in the string array. For some reason it won't work. When i try the java code in eclipse it works.</p>
  
  <p>I already run the debugger and the inputmessage is "Banana". The debugger also shows that message = "Banana" when it is in CheckAnswer(message). But for some reason the function isn't returning "Right". It returns "wrong"</p>
  
  <p>I hope somebody can help me.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>public void sendMessage(View view) {
      // Do something in response to button
      Intent intent = new Intent(this, DisplayMessageActivity.class);
      EditText editText = (EditText) findViewById(R.id.edit_message);
      String message = editText.getText().toString();
      intent.putExtra(EXTRA_MESSAGE, message);
      String message2 = CheckAnswer(message);
      intent.putExtra(CORRECT_MESSAGE, message2);
      startActivity(intent);
  
  }
  
  public static String CheckAnswer(String string) {
      String rightanswer[] = {"Apple", "Banana", "Coconut"};
      String answer = null;
      for (int i = 0; i &lt;= rightanswer.length-1; i++) {
          if (string == rightanswer[i]) {
              answer =  "Right!!";
              break;
          }
          else answer = "Wrong.";
      }
      return answer;
  }
  </code></pre>