Thursday 14 September 2017

Java Class Inheritance

Cited from the Book Java How to Program

public class DrawPanel extends JPanel
{
  ...
}

The keyword extends represents a so-called inheritance relationship in which our new class DrawPanel begins with the existing members (data and methods) from class JPanel. 

In this inheritance relationship, JPanel is called the superclass and DrawPanel is called the subclass. This results in a DrawPanel class that has the attributes (data) and behaviors (methods) of class JPanel as well as the new features we’re adding in our DrawPanel class declaration.

No comments:

Post a Comment