8. Inheritance¶
If there were a way to write Java code so that you could spend more time watching Netflix, would you do it? What if you could write code so that it made it easier for a friend to build onto your program? What if you could write code that made it easier for you to make a few last-minute changes?
If the answer to any of the above questions is yes, then this chapter is for you! In this chapter, we are going to be learning about something called inheritance, which is a topic unique to object oriented programming. It is a very powerful concept that allows you to reuse code that you have already written in other parts of your program without copying and pasting those lines of code!
More specifically, inheritance describes how different classes can be related to one another. Just like you inherited genetic information from your parents, our classes can “inherit” code from their parent classes. We can leverage this relationship in our programs to represent some pretty complex systems all while making our lives easier. Sounds like the sweet life, right?