Misunderstanding of Break
I am just new to learning Java. In the text they show an example of using a break and label. I have tried it in my code but it is not working. Can anyone point me in the right direction.
Included is a copy of the section that is driving me crazy.
toHere: //"This is the label where I wish to jump to"
//"The error I get is the label is not valid
JOptionPane.showMessageDialog (null, intro);
String enterNumber = JOptionPane.showInputDialog (null, "PLEASE ENTER YOUR NUMBER",JOptionPane.QUESTION_MESSAGE);
int enteredValue = Integer.parseInt(enterNumber);
//The do while is used first to create a row of numbers incrementing
do {
//If the number is entered wrong it will advise the user and send the software back to the start.
if ((enteredValue < 10) || (enteredValue > 20)) {
// JOptionPane.showMessageDialog (null,"YOUR NUMBER SHOULD BE \n BETWEEN TEN AND TWENTY");
break toHere;
}
display += numb + gap; //the string is built up as the numbers add
System.out.println (display);
numb++;
} while (numb <= enteredValue);