This is due to the scope of the variable! (Check out page 99-100 for more on scope)
Scope restricts where a variable can and cannot be used. Methods are like containers holding objects (variables). Because of this the variable can only be used within its container (the scope, in this case the method) that it was declared in.
This can also cause issues when you declare a variable within a loop- the variable only exists within the loop, and therefore can not be used or called outside of said loop.
To use a variable across methods it’s important to create a class constant, as described on page 109.
public static final <type> <name> = <expression>;
For example, this is the format for adding a constant which could be called in multiple methods.