Java cycle do while

1

int opc = 0;
do{
  ...
}while (opc != 6);

This error appears to me, I know that I still lack code but I should not mark the cycle with error, no?

    
asked by Angelo Castro 18.07.2016 в 23:08
source

2 answers

2

Because of what you see in the image, the problem is that it is OUT of a function ..

Put something like that

void func() {
    int opc = 0;

    do{
      // ??? 
    } while (opc != 6);
}

Also, just as there is no way out of the loop, it is possible that the code inspector will notice and warn you that the application will be blocked.

Add something that allows the exit, example.

int opc = 0;

do{
  opc ++;
} while (opc != 6);
    
answered by 18.07.2016 / 23:18
source
-2

Do you do a do-while loop but do nothing? What objective would it have.

do{
//???
}while(opc!=6);

Enter the task to be performed and ensure the entire variable exists opt.

int opc = 0;

Check that the code block is really inside a method, it may be the reason why the IDE marks a problem.

link

    
answered by 18.07.2016 в 23:13