/**
 * static methods for arrays
 * @author Suzanne Balik, 6 Nov 2002
 */
public class Array {

  //Return the sum of the numbers in the array
  public static int sum(int[] array) {
    int sum = 0;
    for(int i = 0; i < array.length; i++)
      sum += array[i];
    return sum;
  }

  //Return the minimum value in the array
  public static int min(int[] array) {
    int min = array[0];
    for (int i = 1; i < array.length; i++)
      if (array[i] < min)
        min = array[i];
    return min;
  }
  
  //Return a String representing the array
  //for example: [2, 4, 9]
  public static String getString(int[] array) {
    String s = "[";
    for (int i = 0; i < array.length; i++) {
      s += array[i];
      if (i != array.length - 1)
        s += ", ";
    }
    s += "]";
    return s;
  }
  
  //Return a copy of the array
  public static int[] copy(int[] array) {
    int[] copy = new int[array.length];
    for (int i = 0; i < array.length; i++)
      copy[i] = array[i];
    return copy;
  }
  
  //Return a copy of the array in reverse order
  public static int[] reverse(int[] array) {
      int[] reverse = new int[array.length];
      for (int i = 0, j = array.length - 1; 
                     i < array.length; i++, j--)
      reverse[i] = array[j];
    return reverse;
  }
      

  public static void main(String[] args) {
  

    int[] array = { 3, 5, 2, 8, 1, 6, 7, 9, 10};
    
    
    System.out.println("Minimum value: " + min(array));
    
    System.out.println("Sum: " + sum(array));
    
    System.out.println("Original array:   " + 
                        getString(array));
    
    int[] copyOfArray = copy(array);
    
    System.out.println("Copy of array:    " +  
                        getString(copyOfArray));
    
    int[] reverseOfArray = reverse(array);
    
    System.out.println("Reverse of array: " +  
                        getString(reverseOfArray));
    

  }
}