0

in the InvertingAmplifier constructor I tried to call the super constructor with Amplifier(r1, r2) but it didn't work. I see that super(r1, r2) is the accepted way but I don't understand why.

public  Amplifier( int resistance1, int resistance2)
{
    r1 = resistance1;
    r2 = resistance2;
}

public class InvertingAmplifier extends Amplifier
{
public InvertingAmplifier (int r1, int r2)
{
    super(r1, r2);
}
Chad
  • 159
  • 1
  • 3
  • 15
  • 1
    What do you mean with "it didn't work"? Do you get a compiler error, or a runtime error, or does the program not do what you expect? Explain the problem in more detail. – Jesper Jul 04 '14 at 15:02
  • 1
    You are asking why the language is defined they way it is. Amplifier(r1,r2) is a direct reference to a class, which is invalid. You could have used Amplifier myAmp = new Amplifier(r1,r2), but that would not have done what you appear to want to do. – ErstwhileIII Jul 04 '14 at 15:05
  • This is not really a duplicate of http://stackoverflow.com/questions/1168345/why-does-this-and-super-have-to-be-the-first-statement-in-a-constructor That asks why `super()` must be first. This asks why it is called `super`. – Raedwald Jul 07 '14 at 23:30

0 Answers0