try catch blocks and the effect on variables
In my main function I have a series of try/catch blocks to surround various parts of my code. Unfortunately, the compiler is complaining when I try to use a variable defined in a different try-catch block. It says "cannot find symbol", where the symbol is the variable name. For example,
public class theClass {
public static void main(String[] args) {
try {
int fruity = 1;
} catch (Exception e) { }
try {
fruity = 2;
} catch (Exception e) { }
}
}
The compiler throws an error like "cannot find symbol, symbol: variable fruity".
I presume I'm misunderstanding how the try-catch block works? Any help is appreciated. Thanks!

