1
Chapter 10 Numbers and Statics
•
Static method and Variables
•
Wrapper Class
Two types of methods.
•
Instance methods:
associated with an object and use the instance variables of that
object.
•
Static methods
(also called
class methods
):
use no instance variables of any object
of the class they are defined in.
public
static
double mean(int[] p)
Static methods can be invoked through the class name.
Why declare a method static
•
Documentation
. Anyone seeing that a method is static will know how to call it.
•
Efficiency
. A compiler will usually produce slightly more efficient code because no
implicit object parameter has to be passed to the method.
