Constructor (object-oriented programming): Difference between revisions

Content deleted Content added
Parameterized constructors: remove repetition
Tags: Reverted Mobile edit Mobile web edit
Line 52:
{{see also|Copy constructor (C++)}}
Like C++, Java also supports "Copy Constructor". But, unlike C++, Java doesn't create a default copy constructor if you don't write your own. Copy constructors define the actions performed by the compiler when copying class objects. A Copy constructor has one formal parameter that is the type of the class (the parameter may be a reference to an object). It is used to create a copy of an existing object of the same class. Even though both classes are the same, it counts as a conversion constructor.
While copy constructors are usually abbreviated copy ctor or cctor, they have nothing to do with class constructors used in .NET using the same abbreviation.
[[K1f3:)]] //k show//
 
=== Conversion constructors ===