Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## utilities
Class MyMath

    java.lang.Object
      |
      +--utilities.MyMath

public class MyMath
extends java.lang.Object

Constructor Summary
`MyMath()`

Method Summary
`static int` | `factorial(int n)`
`static void` | `main(java.lang.String[] args)` Test integer MyMath methods.
`static int` | `max(java.lang.Comparable[] a, int n)` generic method to find maximum object in a[0:n]
`static Computable` | `sum(Computable[] a, int n)` Generic sum method.
`static int` | `sum(int[] a, int n)`
`static void` | `swap(int[] a, int i, int j)` Swap the integers a[i] and a[j].
`static void` | `swap(java.lang.Object[] a, int i, int j)` Generic method to swap the object references a[i] and a[j].

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### MyMath

    public MyMath()

Method Detail

### sum

    public static int sum(int[] a,
                          int n)

  Returns:
    sum of the integers a[0:n-1]

### sum

    public static Computable sum(Computable[] a,
                                 int n)

  Generic sum method.
  Returns:
    null if array has no objects and sum of the objects a[0:n-1] otherwise

### swap

    public static void swap(int[] a,
                            int i,
                            int j)

  Swap the integers a[i] and a[j].

### swap

    public static void swap(java.lang.Object[] a,
                            int i,
                            int j)

  Generic method to swap the object references a[i] and a[j].

### factorial

    public static int factorial(int n)

  Returns:
    n!

### max

    public static int max(java.lang.Comparable[] a,
                          int n)

  generic method to find maximum object in a[0:n]
  Returns:
    position of max element in a[0:n]
  Throws:
    java.lang.IllegalArgumentException - when n < 0

### main

    public static void main(java.lang.String[] args)

  Test integer MyMath methods. The generic methods are tested by MyInteger.main.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD