previous |
start |
next
Static Methods
- Every method must be in a class
- Some methods have no implicit parameter
- E.g. if all parameters are primitive
class Numeric
{ public static boolean
approxEqual(double x, double y)
{ . . .
}
}
- Call with class name instead of object:
if (Numeric.approxEqual(a, b)) . . .
- main is static--there aren't any objects yet
- Too many static methods are a sign of too little OO
previous |
start |
next