Inheritance concept java..help
- by max
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();
}
}