Copy Constructor in Java
Prerequisite – Constructors in Java
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.
Following is an example Java program that shows a simple use of copy constructor.
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.
Copy constructor called (10.0 + 15.0i)
Now try the following Java program:
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.