About 50 results
Open links in new tab
  1. oop - Constructors in JavaScript objects - Stack Overflow

    Jul 11, 2009 · Using Nick's sample above, you can create a constructor for objects without parameters using a return statement as the last statement in your object definition.

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

    Apr 11, 2009 · 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 …

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

    May 12, 2010 · 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 …

  4. What are the rules for calling the base class constructor?

    1189 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 …

  5. Java Constructors - Stack Overflow

    Aug 21, 2016 · 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 …

  6. Using C++ base class constructors? - Stack Overflow

    Nov 11, 2011 · Here is a good discussion about superclass constructor calling rules. You always want the base class constructor to be called before the derived class constructor in order to form an object …

  7. Difference between Constructor and ngOnInit - Stack Overflow

    Mar 3, 2016 · The Constructor is a default method of the class that is executed when the class is instantiated and ensures proper initialisation of fields in the class and its subclasses. Angular, or …

  8. angular - ESLint complaining about empty constructor and ngOnInit ...

    Mar 14, 2021 · The linter is correct: your constructor parameter lacks a visibility modifier, so it isn't a parameter property, so that constructor is indeed empty (and has an unused parameter).

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

    Nov 13, 2013 · A constructor is used to create an instance of the class Card. And you'll need to call it 52 times to have 52 cards: new Card(1, "hearts"), etc. Now each instance of Player (you also need a …

  10. Using 'this' keyword in Java constructors - Stack Overflow

    In the constructor, this(...) is like a method call for constructors. The compiler chooses which constructor to call based on the number and types of the arguments you use.