the ``final'' keyword, when applied to a variable, means the variable's value is constant.
e.g.
the variable RED cannot now be given another value. If you are familiar with C, it is analogous to the following:
The ``final'' keyword is useful when applied to variables whose values will not change during the lifetime of the program. If you've got constant values in your program which will not change throughout, it is useful to declare them as final.
The keyword ``static'' when applied to a variable OR a method means that the variable or method can be accessed without creating an instance of the class.
For examples of static variables see the Color class in the Java API. It uses static variables such as BLACK, BLUE, PINK etc.
They can be referenced like:
Code:
useColor(Color.BLACK);
instead of
Code:
Color myColorBlack = new Color();
useColor(myColorBlack.BLACK);
static can be used for methods for much the same effect.
When ``final'' is applied to a class, the principle effect is that the class cannot be inherited from. For example, the following would throw an error:
Code:
public final class Dog {
public Dog() {
}
}
public class JackRussell extends Dog {
public JackRussell() {
}
}
For more information on the static keyword, see:
http://www.javacoffeebreak.com/faq/faq0010.html
Phil