Home Segments Top Top Previous Next

249: Mainline

Fortunately, Java encourages you to cut down on duplication—thereby easing program developing, debugging, and maintenance—by allowing you to arrange class definitions in hierarchies that reflect natural category hierarchies.

Using Java, you can say, for example, that movies and symphonies are attractions. Then, you can declare a minutes instance variable in the Attraction class alone, because the minutes instance variable will appear in each Movie instance and Symphony instance, as though minutes had been declared in each.