Content deleted Content added
No edit summary |
No edit summary |
||
Line 1:
In [[object-oriented programming]], a '''constructor''' (sometimes shorted to '''ctor''') in a class is a special block of statements called when an object is declared (statically constructed, possible in C++ but not in Java and other OO languages) or dinamically constructed trough the new keyword. A constructor is similar to [[method (computer science)|class methods]], but it is not a special kind of method, because it never has a return type, it's not inherited, and usually has different rules for modifiers. Constructors are simply special block of statements that are called
=== [[Java programming language|Java]] ===
Line 6:
*Constructors never have a return type.
*Constructors can't be directly invoked ("new" keyword must be used)
*Constructors can't be overridden, nor they are inherited
*Constructors shouldn't call other overridable methods
|