Inheritance concept java..help

Posted by max on Stack Overflow See other posts from Stack Overflow or by max
Published on 2010-12-23T22:32:48Z Indexed on 2010/12/23 22:54 UTC
Read the original article Hit count: 148

Filed under:
|

Hi everyone. I'd be very grateful if someone could help me to understand the inheritance concept in Java. Is the following code an example of that?

I mean the class WavPanel is actually a subclass of JPanel which acts as a superclass.

Is that correct?

If so it means that "what JPanel has, also WavPanel but it is more specific since through its methods you can do something else".

Am I wrong?

thank you. Max

import javax.swing.JPanel;
class WavPanel extends JPanel {

        List<Byte> audioBytes;
        List<Line2D.Double> lines;

        public WavPanel() {
            super();
            setBackground(Color.black);
            resetWaveform();
        }

        public void resetWaveform() {
            audioBytes = new ArrayList<Byte>();
            lines = new ArrayList<Line2D.Double>();
            repaint();
        }
}

© Stack Overflow or respective owner

Related posts about java

Related posts about inheritance