So i have this code and i want when the user types A to activate the while(attack) which has is below this code so it doesnt work with continue attack; I placed a label called a
Labels don't work like this. In Java, there is no goto label
functionality. Labels are used when you have inner loops and you need to break
or continue
an outer loop, like in the following example:
outterloop:
for (int i = 0; i < 10; i++) {
for (int j = 0; j < 10; j++) {
// this would break the inner loop and go to the next outter loop iteration
// break;
// this would break the outter loop, thus exiting both loops
// break outterloop;
// this would jump to the next inner loop iteration
// continue;
// this would jump to the next outter loop iteration, exiting the inner loop
// continue outterloop;
}
}
What you need is to improve your code structure to achieve what you want without the need of labels.
https://docs.oracle.com/javase/tutorial/java/nutsandbolts/branch.html