Content deleted Content added
m robot Modifying: fr |
Constructors are NOT methods |
||
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 or explicitally constructed trough the new keyword, depending by the language. A constructor is similar to [[method (computer science)|
=== [[Java programming language|Java]] ===
Some of the differences between Java methods and constructors:
*Constructors never have a return type.
*Constructors can't be overridden, nor they are inherited
*Constructors shouldn't call other overridable methods
*Constructors can't be synchronized
*Constructors are always executed by the same thread
*Constructors can't be final
*Constructors can't be abstract
==== Example ====
public class Example
Line 90 ⟶ 101:
==References==
* [[Bjarne Stroustrup]]: ''The C++ Programming Language'', Addison-Wesley, ISBN 0-201-70073-5
* [[James Gosling]]: ''The Java Programming Language'', Addison-Wesley, ISBN 0-321-34980-6
[[Category:Programming constructs]]
|