FileDocCategorySizeDatePackage
Complex.javaAPI DocExample1184Wed Apr 20 15:16:58 BST 2005None

Complex

public class Complex extends Object
This immutable class represents complex numbers.
author
David Flanagan
version
1.0

Fields Summary
protected double
x
Holds the real part of this complex number.
protected double
y
Holds 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.

param
x The real part of the complex number.
param
y The imaginary part of the complex number.

        this.x = x;
        this.y = y;
    
Methods Summary
public static Complexadd(Complex c1, Complex c2)
Adds two Complex objects and produces a third object that represents their sum.

param
c1 A Complex object
param
c2 Another Complex object
return
A new Complex object that represents the sum of c1 and c2.
exception
java.lang.NullPointerException If either argument is null.

        return new Complex(c1.x + c2.x, c1.y + c2.y);