package com.concretepage;
public class Main {
public static void main(String[] args) {
Complex complex1 = new Complex(10, 15);
Complex complex2 = new Complex(complex1);
Complex complex3 = complex2;
System.out.println(complex2);
}
}
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
package com.concretepage;
public class Complex {
private double re, im;
public Complex(double re, double im) {
this.re = re;
this.im = im;
}
Complex(Complex c){
System.out.println("Copy Constructor called");
re = c.re;
im = c.im;
}
@Override
public String toString() {
return "(" + re + " + " + im + "i)";
}
}
public class Main {
public static void main(String[] args) {
Complex complex1 = new Complex(10, 15);
Complex complex2 = new Complex(complex1);
Complex complex3 = complex2;
System.out.println(complex2);
}
}
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
package com.concretepage;
public class Complex {
private double re, im;
public Complex(double re, double im) {
this.re = re;
this.im = im;
}
Complex(Complex c){
System.out.println("Copy Constructor called");
re = c.re;
im = c.im;
}
@Override
public String toString() {
return "(" + re + " + " + im + "i)";
}
}
No comments:
Post a Comment