Complexe.java

public class Complexe {
  protected double partieRéelle;
  protected double partieImaginaire;
  public Complexe(double r, double i) {
    partieRéelle = r;
    partieImaginaire = i;
  }
  public String toString() {
    return partieRéelle+"+"+partieImaginaire+"i";
  }
  public static void main(String[] args) {
    Complexe c = new Complexe(1.0,2.0);
    System.out.println(c.toString()); // affiche 1.0+2.0i
  }
}