Chapter 11. Packages

When you start creating Java applications and other programs, you will probably discover that those programs contain classes and interfaces that can be reused. Rather than duplicate your effort by re-creating those classes and/or interfaces, you can organize them into packages—your own class libraries. The next time you need a commonly used class or interface, you won't have to “reinvent the wheel.” Instead, you'll simply access the class or interface from a package. This chapter introduces the concept of packages, examines the Package and Import directives that you use when creating and accessing packages, and shows you how to create your own packages.

What Are Packages?

Imagine a file system that stores all files in one directory. ...

Get Java™ 2 by Example, Second 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.