Tuesday, 15 June 2010

java - If and else condition running together -


I have written a simple for loop with an IF-another block for the Android app. The I code looks like this:

 for  (int i = 0; i & lt; ques.length; i ++) {int attempt = 0; Int j = i + 1; Ans1 = t.getText (). ToString (); If (ans1.equals (ans [i])) {qView.setText (""); T.setText (""); Aview.setText (""); If (j! = Ques.length) {aview.append ("Attempt: 0"); QView.append (question [ja]); } And qView.append ("Congratulations! You have completed the quiz"); } {Attempt ++; Aview.setText ("wrong"); //aview.append(- try: "+ effort);}  

When I run the app and if I enter the correct answer to match the condition, then order T.setText ("") and qView. Settext ("") are executed, however for observation, under else command (aview.setText ("wrong ")) is executed. Why is this happening? How is it possible that if and other blocks are being executed for the same input?

to use Try:

  break;  

after

qView.append ("Congratulations! You complete the quiz Have done ");

No comments:

Post a Comment