约 50 个结果
在新选项卡中打开链接
  1. What are the rules for calling the base class constructor?

    1190 Base class constructors are automatically called for you if they have no argument. If you want to call a superclass constructor with an argument, you must use the subclass's constructor initialization …

  2. Can I call a constructor from another constructor (do constructor ...

    2008年11月21日 · When calling a constructor it actually allocates memory, either from the stack or from the heap. So calling a constructor in another constructor creates a local copy.

  3. function - Purpose of a constructor in Java? - Stack Overflow

    2013年11月13日 · What is the purpose of a constructor? I've been learning Java in school and it seems to me like a constructor is largely redundant in things we've done thus far. It remains to be seen if a …

  4. What's the difference between an object initializer and a constructor?

    A constructor is a defined method on a type which takes a specified number of parameters and is used to create and initialize an object. An object initializer is code that runs on an object after a constructor …

  5. Can an abstract class have a constructor? - Stack Overflow

    2008年11月4日 · The same case applies to abstract classes. Though we cannot create an object of an abstract class, when we create an object of a class which is concrete and subclass of the abstract …

  6. Can a constructor in Java be private? - Stack Overflow

    2010年5月12日 · Yes, a constructor can be private. There are different uses of this. One such use is for the singleton design anti-pattern, which I would advise against you using. Another, more legitimate …

  7. .NET Core DI, ways of passing parameters to constructor

    2018年12月21日 · Having the following service constructor public class Service : IService { public Service(IOtherService service1, IAnotherOne service2, string arg) { } } What are the choices of

  8. c++ - Initializing fields in constructor - initializer list vs ...

    6 In your example code, the first one in constructor initialization and second one is assignment inside constructor body. Constructor initialization list is the best way to do all member initialization because …

  9. Java Constructors - Stack Overflow

    2016年8月21日 · The constructor arguments allow you to provide parameters for the initialization of an object. In this example, you can create a Bicycle object with a gear of 1, cadence of 0, and a speed …

  10. c# - Call asynchronous method in constructor? - Stack Overflow

    2014年4月14日 · By making the constructor private and keeping the static method within the same class we have made sure that no one could "accidentally" create an instance of this class without calling …