Although most methods execute on specific objects in response to method calls, this is not always the case. Sometimes a method performs a task that does not depend on the contents of any object. Such a method applies to the class in which it’s declared as a whole and is known as a
static method. It’s not uncommon for a class to contain a group of
static methods to perform common tasks. For example, recall that we used
Pow of class
Math to raise a value to a power in Fig. 6.6. To declare a method as
static, place the keyword
static before the return type in the method’s declaration. You call any
static method by specifying the name of the class in which the method is declared, ...