In this section, we'll take a quick look at an important idea that relates to inheritance in Java. To wrap our heads around what we're going to talk about, I think it's best if we start an existing project in the system. So let's take a look at the code we have in the code files.
So far, we've done the following:
- The main method of our program creates a list of objects. These objects are either of the type Book or Poem, but we've placed them in a list of Literature objects, leading us to believe that the Book and Poem classes must inherit from or extend the Literature class.
- Once we've built this array, we simply iterate through it using a for loop and call the Print method of this for loop on each object.
- At this point, we're dealing with objects as Literature objects, not the Books or Poems that they are at the lowest level....