- If you need a variable with a value that is accessible everywhere, then
define a public class variable by instantiating the following pattern:
public static data type variable name;
- If you want to access the value of a public class variable, then
instantiate one of the following patterns:
... class name.variable name ...
class name.variable name = new-value expression;
- If you want a variable to be a constant, then add the keyword
final to the variable declaration, and be sure to initialize the
variable in the declaration statement.
public static final data type variable name
= new-value expression;