Section 6.2 Program Modules in Java

• Methods are declared within classes. Classes are typically grouped into packages so they can be imported and reused.

• Methods allow you to modularize a program by separating its tasks into self-contained units. The statements in a method are written only once and hidden from other methods.

• Using existing methods as building blocks to create new programs is a form of software reusability (p. 202) that allows you to avoid repeating code within a program.

Get Java™ How To Program (Early Objects), Tenth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.