Chapter 18. Building Class Hierarchies

In Chapter 1, “Introduction to Java,” we mentioned that one of the strengths of Java is that it allows you to develop class hierarchies. Hierarchies help you to organize your code and they facilitate code reuse. Because of inheritance, you can place common methods higher in the class hierarchy so they can be accessed by any number of classes lower in the hierarchy. In this chapter, we will go through the process of designing and implementing a class hierarchy to model a gas mixture, but the concepts and design strategies demonstrated here are applicable to all class hierarchies.

Developing class hierarchies is as much a design problem as it is one of programming. You must first think about the best way to ...

Get Technical Java™: Developing Scientific and Engineering Applications 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.