Παράδειγμα υπερφόρτωσης μεθόδων


double
square(final double x)
{
  return x * x;
}

Complex
square(final Complex x)
{
  return new Complex(
    square(x.real) + square(x.imaginary),
    2 * x.real + x.imaginary);
}