I am trying to do this:
public class Demo{ public Demo() { Demo(null) } public Demo(Interface myI) { ... } }
I would like the Demo() constructor to call the Demo(Interface) constructor with null , however eclipse complains: "Demo (null) - undefined" on the line where I call Demo(null) . What do i need to change?
Demo()
Demo(Interface)
null
Demo(null)
You are trying to call a method called Demo that you did not define.
Demo
eg.
class A { public A() { this(1); // calls constructor A(int) A(1); // calls method A(int) } public A(int i) {} // constructor A(int) public void A(int i) {} // method A(int) public AA(A a) { return a; } // method A(A) which returns A }
If you want the constructor to call another, you need to use this() as
this()
public Demo() { this(null); }
It should not be Demo(null) , but this(null)
this(null)
Source: https://habr.com/ru/post/1443248/More articles:SSRS strings - RDL Tablix not paginated - reporting-servicesJIT Spacetree Save Shortcuts As Image - javascriptXmlSerializer - How to set the default value when deserializing an enumeration? - c #JIT - Saving Spacetree as Image - javascriptPredefined macros for method names - c #How to detect dns changes in C #? - c #LinqToSql converts a single C # variable to multiple SQL parameters - c #How to drown after_create callback save! in the model? - ruby | fooobar.comInteraction with the C / C ++ procedure in C # causes rip - c #Factory installation problem - phabricatorAll Articles