Top "Constructor" questions

A special type of subroutine called at the creation of an object.

Constructor overloading in Java - best practice

There are a few topics similar to this, but I couldn't find one with a sufficient answer. I would like …

java constructor overloading constructor-overloading
Chain-calling parent initialisers in python

Consider this - a base class A, class B inheriting from A, class C inheriting from B. What is a …

python oop inheritance constructor
Serialize JavaScript object into JSON string

I have this JavaScript prototype: Utils.MyClass1 = function(id, member) { this.id = id; this.member = member; } and I create a …

javascript json constructor
Is there a way to @Autowire a bean that requires constructor arguments?

I'm using Spring 3.0.5 and am using @Autowire annotation for my class members as much as possible. One of the beans …

spring constructor autowired spring-annotations spring-bean
How to call Base Class's __init__ method from the child class?

If I have a python class as: class BaseClass(object): #code and the init function of the base class And …

python python-2.7 inheritance constructor
Calling the base class constructor from the derived class constructor

I have a question: Say I have originally these classes which I can't change (let's say because they're taken from …

c++ inheritance constructor visibility derived-class
How to start an Intent by passing some parameters to it?

I would like to pass some variables in the constructor of my ListActivity I start activity via this code: startActivity(…

android constructor android-intent
Is it good practice to make the constructor throw an exception?

Is it a good practice to make the constructor throw an exception? For example I have a class Person and …

java exception constructor
C++ template constructor

I wish to have a non-template class with a template constructor with no arguments. As far as I understand, it's …

c++ templates constructor
Call asynchronous method in constructor?

Summary: I would like to call an asynchronous method in a constructor. Is this possible? Details: I have a method …

c# windows-phone-8 constructor visual-studio-2013 async-await