Class or static Members
| |||
A method or a field in a
Java program can be declared If a variable is static, then when any object in the class changes the value of the variable, that value changes for all objects in the class. One possible use of static
methods and members is to add version information to a class. A static Another good reason to make a method static is if it neither accesses nor modifies any of the instance (non-static) fields of a class and it does not invoke any non-static methods in the class. This is common in calculation methods like a square root method that merely operate on their arguments and return a value. | |||
|