"input cannot be resolved" when added a try..catch

Posted by Mark on Stack Overflow See other posts from Stack Overflow or by Mark
Published on 2013-10-17T21:48:11Z Indexed on 2013/10/17 21:53 UTC
Read the original article Hit count: 207

Filed under:

I originally tried to get my throw statement to work without a try catch and the userInput = input.nextInt(); line worked fine. But when I tried adding the try..catch it didn't like my input saying it cannot be resolved. I don't think my try..catch is correct yet but I am planning on tackling that after I can get this input to be recognized but I would appreciate any feedback on things you see with that as well.

Thanks

import java.util.Scanner;

    public class Program6 
    {
        public static void main(String[] args) 
        {
            final int NUMBER_HIGH_LIMIT = 100;
            final int NUMBER_LOW_LIMIT = 10;
            int userInput;

            try
            {
                System.out.print("Enter a number between 10 and 100: ");
                userInput = input.nextInt();//Says input cannot be resolved

                Verify v = new Verify(NUMBER_HIGH_LIMIT, NUMBER_LOW_LIMIT);
            }
            catch(NumberHighException exception)
            {
                userInput = 0;
            }
            catch(NumberLowException exception) 
            {
                userInput = 0;  
            }
        }
    }

© Stack Overflow or respective owner

Related posts about java