|
Accessibility
e.g. public int numberDice;
// public access Final The final keyword indicates that a variable is being given a value that can not be changed. e.g. final int numberDice = 2; // the value
can not be changed Static The static keyword indicates that only one instance of the variable will be created and then shared among every instance of a class. e.g. static int numberDice; In the first example, every instance of a class shares the same variable. If one instance changes the value of numberDice, it changes for all other instances. In the second example, every instance of a class gets its own version of the variable. Thus, each instance could potentially have a different value for the numberDice variable. |