title: return largest element of array
body: <pre><code>package Prac;
  
  import java.io.*;
  import java.util.*;
  
  public class Practice {
  
      public static void main(String [] args){
          int[] test = {0,1,2,99,4,5};
  
          int maximum = max(test);
          System.out.print(maximum);
      }
  
      public static int max(int[] test1){
          int max =0;
          for(int i = 0; i &lt;=test1.length;i++){
              if(test1[i]&gt;=max){
                  max=test1[i];
              }
          }   
          return max;
      }
  }
  </code></pre>
  
  <p>//
      Java doesn't show an errors until I run this program and it gives me:</p>
  
  <pre><code>//Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException:     6
  //at Prac.Practice.max(Practice.java:18)
  //at Prac.Practice.main(Practice.java:9)
  </code></pre>
  
  <p>// I am supposed to write a method that takes an array of ints as a parameter and returns the largest element of the array.</p>