Methods and
Abstraction
Writing methods allows for
abstraction in problem
solving. Method abstraction
separates the use of a
method from its
implementation.
No details are necessary for
the specific tasks of getting
lottery numbers, setting the
Powerball, or displaying the
numbers. The logical flow of
the solution can be
developed and tested.
Value-returning vs
void methods
Methods are either value returning or void.
When writing a value-returning method,
ensure that all control paths return a value.
When calling a value-returning method,
ensure that the calling block of code utilizes
the return value. In most cases, value-
returning methods calculate and return
some value or set of values.
void methods do not return a value. In most
cases, void methods perform some task,
such as displaying lottery numbers.