Complexpublic class Complex extends Object This immutable class represents complex numbers. |
Fields Summary |
---|
protected double | xHolds the real part of this complex number. | protected double | yHolds the imaginary part of this complex number. |
Constructors Summary |
---|
public Complex(double x, double y)Creates a new Complex object that represents the complex number x+yi.
this.x = x;
this.y = y;
|
Methods Summary |
---|
public static Complex | add(Complex c1, Complex c2)Adds two Complex objects and produces a third object that represents
their sum.
return new Complex(c1.x + c2.x, c1.y + c2.y);
|
|