Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #36111

Re: I don't understand why the following doesn't call Rectangle

Newsgroups comp.lang.java.programmer
Date 2016-12-13 08:20 -0800
References <45806188-ffb3-4173-aaf0-48c84655fa85@googlegroups.com> <f58fc886-d35f-4d90-8286-c6e9cb949115@googlegroups.com> <94441613-81a8-4d22-8230-09735e5a91ae@googlegroups.com>
Message-ID <cd2fbc55-7b24-4372-8e6a-bf9826a7e04a@googlegroups.com> (permalink)
Subject Re: I don't understand why the following doesn't call Rectangle
From Eric Douglas <e.d.programmer@gmail.com>

Show all headers | View raw


On Tuesday, December 13, 2016 at 11:06:46 AM UTC-5, cda...@gmail.com wrote:
> I think I have some serious misconceptions on how super() works. Also, is constructing a ComparableRectangle the same thing as constructing a ComparableRectangle object?

The values in the constructor is what you're missing.  When you specify a value without calling super you're calling the super constructor without the value.  Try the following test with and without the super.


public class TestClass1 {
     private int value = 0;
     public TestClass1() {
          
     }
     public TestClass1(int setValue) {
          value = setValue;
     }
     public int getValue() {
          return value;
     }
}
public class TestClass2 extends TestClass1 {
     public TestClass2(int setValue) {
          super(setValue);
     }
     public static void main(String[] args) {
          TestClass2 testMe = new TestClass2(6);
          System.out.println(testMe.getValue());
     }
}

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

I don't understand why the following doesn't call Rectangle cdalten@gmail.com - 2016-12-13 07:42 -0800
  Re: I don't understand why the following doesn't call Rectangle Eric Douglas <e.d.programmer@gmail.com> - 2016-12-13 07:52 -0800
    Re: I don't understand why the following doesn't call Rectangle cdalten@gmail.com - 2016-12-13 08:06 -0800
      Re: I don't understand why the following doesn't call Rectangle Eric Douglas <e.d.programmer@gmail.com> - 2016-12-13 08:20 -0800
  Re: I don't understand why the following doesn't call Rectangle Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-12-13 11:42 -0500
  Re: I don't understand why the following doesn't call Rectangle lewbloch@gmail.com - 2016-12-13 12:47 -0800
    Re: I don't understand why the following doesn't call Rectangle Manuel Collado <m.collado@domain.invalid> - 2016-12-14 19:13 +0100

csiph-web