CHAPTER 9

Creating Packages and Using Access Specifiers

What is a package in Java? In Java, package is a collection of related classes and interfaces. Just like we organize our files into folders, we normally have a Documents folder to keep all document files, a Music folder to keep all music files, a Videos folder to keep all video files; similarly we organize our classes and interfaces in Java into various packages.

In the earlier chapters and exercises, we have defined a few classes like the Rectangle and the Cuboid classes in Chapter 6 and then the Account, SavingsAccount and the CurrentAccount classes in Exercise 8.1. Now the classes like Rectangle and Cuboid are related to geometrical shapes, and the Account, SavingsAccount and the CurrentAccount ...

Get The class of Java 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.