I have a program, which takes a parameter from the args[] array, defined in the main method, but has a backup in case that isn't defined, in the form of a try...catch block, which, if an ArrayIndexOutOfBounds exception is thrown, instead uses a method called getInt to prompt the user to enter a variable. But, for some reason, when I try to use that variable, my compiler says that it cannot find it. I have the following code:
try {
int limit = Integer.parseInt(args[0]);
}
catch(ArrayIndexOutOfBoundsException e) {
int limit = getInt("Limit? ");
}
int[] p = getPrimes(limit);
getPrimes is another method I have, which returns an array of prime numbers starting from 2 and up to a specified number (using the Sieve of Atkin). Anyway, when I write int[] p = getPrimes(limit); and try compiling, it says that the "limit" variable is not defined. Help please!