title: How to compare a string and a character array in android?
body: <p>I have a string <code>"sss"</code> and a character array <code>{'s','s','s'}</code>. I converted the array to string but the message <strong>"both are equal"</strong> is not printed upon comparing them. Why? </p>
  
  <pre><code>public class RoughActivity extends Activity 
  {
   private Button checkButton;
   private TextView text;
  
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);
          start();
          }
  
          private void start() {
              int i;
              checkButton=(Button)findViewById(R.id.go);
              text=(TextView)findViewById(R.id.display);
              final String question="sss";
              final char answer[]=new char[question.length()];
              for(i=0;i&lt;question.length();i++)
              {
                  answer[i]='s';
              }
              checkButton.setOnClickListener(new View.OnClickListener(){ //on clicking the button,the text must be filled with "both are equal"
                  public void onClick(View v){
                      if(question.equals(answer))
                      {
                          text.setText("both are equal");
                      }
  
  
                  }});
  }
  }
  </code></pre>