Labels in Java for exception handling
<p>I'm doing the Java Associate level certification and while we are expressly told we won't be tested on labels, we have been shown them. Looking on here though the advice seems to be never use labels?</p>

<p>I'd like to use them in a catch block/user input console as a means of validating input. </p>

<pre><code>do {//Keep calculator going as long as user wants               
            numInputCheck: 
            do {
                try {//Force user to input a whole number
                    System.out.print("\nPlease enter the Mark you want to Calculate\n(Enter marks between " + GradeCalculator.getMIN_MARK() + " and " + GradeCalculator.getMAX_MARK() + " only): ");
                    mark = Integer.parseInt(scn.nextLine());
                }catch(NumberFormatException nfe) {
                    System.out.println("\nInvalid entry - Please ensure entry is a number only.");
                    continue numInputCheck;
                }   
                gradeCalc.isValidMark(mark);//Ensure input is within valid range
            }while(!gradeCalc.getIsValidMark());
            *etc*......
</code></pre>

<p>Is this bad coding? </p>

<p>EDIT: The code above wasn't doing what I thought it was/wanted it to do - it wasn't actually jumping back to the label at all.</p>

<p>I ended up changing the code to</p>

<pre><code>do {//Keep calculator going as long as user wants
            do {//Force user to enter number within valid range
                do {//Force user to enter a whole number
                    try {
                        System.out.print("\nPlease enter the Mark you want to Calculate\n(Enter marks between " + GradeCalculator.getMIN_MARK() + " and " + GradeCalculator.getMAX_MARK() + " only): ");
                        mark = Integer.parseInt(scn.nextLine());
                        isValidInput = true;
                    }catch(NumberFormatException nfe) {
                        System.out.println("\nInvalid entry - Please ensure entry is a number only.");
                        isValidInput = false;
                    }
                }while(!isValidInput);
            }while(!gradeCalc.isValidMark(mark));
</code></pre>

<p>which I'm <em>fairly</em> sure is working correctly.</p>

<p>Anyway, I think I answered my own question - labels are discouraged because people like me try to use them.</p>