9 Packages and Interfaces

9.1 INTRODUCTION

A packing is a grouping of related types providing access protection and name space management. Note that all types refer to classes and interfaces. Many a time while working on a small project, one thing that is intended to do is to put all Java files into a single directory. It is quick, easy and harmless. However, if the small project gets bigger and the number of files keeps on increasing, putting all these files into the same directory and managing them would be a difficult task. In Java, this sort of problem can be avoided by using package.

Packages are nothing more than the way files are organized into different directories according to their functionality, usability as well as category they ...

Get Java Programming 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.