I have a string "sss" and a character array {'s','s','s'}. I converted the array to string but the message "both are equal" is not printed upon comparing them. Why?
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<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");
}
}});
}
}