error : while expected /eached end of file while Parsing

Asked

Viewed 41 times

-2

Guys I’m having problems with my Bingo app

public class MainActivity extends AppCompatActivity {
    int[] ids = {R.id.button2, R.id.button3, R.id.button4, R.id.button5, R.id.button6, R.id.button7,
            R.id.button8, R.id.button9, R.id.button10, R.id.button11, R.id.button12, R.id.button13, R.id.button14,
            R.id.button15, R.id.button16, R.id.button17, R.id.button18, R.id.button19, R.id.button20, R.id.button21,
            R.id.button22, R.id.button23, R.id.button24, R.id.button25, R.id.button26};
    int cont = 0;
    int[] vetaux = new int[25];
    boolean isRepetido = false;
    Random sorteador = new Random();
    int n1 = 0;
    boolean y = false;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        do {
            n1 = sorteador.nextInt(100);
            for (int cont1 = 0; cont1 < cont; cont1++) {
                if (vetaux[cont1] == n1) {
                    y = true;
                    break;
                } else {
                    y = false;
                }
            }
            if (y == false) {
                vetaux[cont] = n1;
                cont++;
            }
            while (cont < 25) ;
            {
            //int Nsorteado = sorteador.nextInt(100);//Nsorteado armzenou o numero
            for (int cont = 0; cont < ids.length; cont++) {
                int Id = ids[cont];
                int n1 = vetaux[cont];
                String txt1 = String.valueOf(n1);
                Button button = (Button) findViewById(Id);
                button.setText(txt1);
            }

        }
    } 
}

error : while expected error :reached end of file while Parsing

  • I advise you to read a little bit about https://answall.com/help/how-to-ask, and also to thank users who are taking the time to help with their questions.

  • in front of your while has a dot and comma remove it and see if it works

  • @Ezequielmessore if he removes ; where will know the end of "while..." ??

  • @Matheus the scope of while is bounded by the example keys: while(i<10){ } vc do not need the dot and comma to know where the end is

  • Yes while yes, but he is using a do.. while it is also used keys, but keys happen before calling while

  • @Please ignore me Matheus now that I’ve noticed that it’s a do/while ...

  • galara...problem solved ...the problem was in closing in

  • do{ }while;{ } thank you all...I’m new here and would like to know how to thank the users who helped me

Show 3 more comments

1 answer

0


You opened keys after performing one of the while, as if it were a normal while, try this, remove that { only one who stands after his while:

public class MainActivity extends AppCompatActivity {
int[] ids = {R.id.button2, R.id.button3, R.id.button4, R.id.button5, R.id.button6, R.id.button7,
        R.id.button8, R.id.button9, R.id.button10, R.id.button11, R.id.button12, R.id.button13, R.id.button14,
        R.id.button15, R.id.button16, R.id.button17, R.id.button18, R.id.button19, R.id.button20, R.id.button21,
        R.id.button22, R.id.button23, R.id.button24, R.id.button25, R.id.button26};
int cont = 0;
int[] vetaux = new int[25];
boolean isRepetido = false;
Random sorteador = new Random();
int n1 = 0;
boolean y = false;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    do {
        n1 = sorteador.nextInt(100);
        for (int cont1 = 0; cont1 < cont; cont1++) {
            if (vetaux[cont1] == n1) {
                y = true;
                break;
            } else {
                y = false;
            }
        }
        if (y == false) {
            vetaux[cont] = n1;
            cont++;
        }
        while (cont < 25) ;
        //int Nsorteado = sorteador.nextInt(100);//Nsorteado armzenou o numero
        for (int cont = 0; cont < ids.length; cont++) {
            int Id = ids[cont];
            int n1 = vetaux[cont];
            String txt1 = String.valueOf(n1);
            Button button = (Button) findViewById(Id);
            button.setText(txt1);
        }

    }
} 


}
  • tried, but to no avail...

  • Still the same mistake ?

  • yes ...continua while expected.... and reached end of file while Parsing

  • Then the error must be in another part of your code, because this error happens due to excess or lack of keys in the code

  • @Ezequielmessore no matter where the go has to be, his error is just a syntax error of the language, he is forgetting to add or remove the keys...

Browser other questions tagged

You are not signed in. Login or sign up in order to post.