Double的Complex()的方法

class Complex{

//instance variables
double real,imag;


public static void main(String args[]){
Complex a=new Complex(1.0,1.1);
Complex b=new Complex(1.0,1.1);
boolean c=a.equals(b);
System.out.println(c);
}


//constructor
public Complex(){
this.real=0.0;this.imag=0.0;
}

//constructor
public Complex(double real,double imag){
this.real=real;this.imag=imag;
}

public boolean equals(Complex b){
if(b==null) return false;
return (real==b.real && imag==b.imag);
}
}

你可能感兴趣的:(Java,C,C++,C#)