title: How to iterate through array and find highest value: Java
body: <p>In the Bellow code I am supposed to find the month that correlates with the largest number. </p>
  
  <p>Bellow is what I tried. However I belive that there is likly a more consice way to write this. How can I make it that way?</p>
  
  <pre><code>public class HelloWorld{
  
  static int[] array = {3,6,7,3,2,30,9,13,12,1,2,1};
  static String[] month = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};
  
  static int greatestVal = 0;
  static int greatestVal2 = 0;
  static String monthChosen = "";
  
  int integer = 0;
  static int num = 0;
  
       public static void main(String []args){
              int number = -1;
              for (int i = 0; i&lt;=11; i++) {
                  int currentValue = array[i];
                  number += 1;
                  //System.out.println(currentValue);
                  for (int index = 0; index &lt;=11; index++) {
                      if (currentValue &gt; array[index]) {
                          greatestVal = currentValue;
                          // System.out.println(currentValue +"&gt;"+ array[index]);
                          if (greatestVal &gt; greatestVal2) {
                              greatestVal2 = greatestVal;
                              monthChosen = month[number];
                          }
                      } else {
                          // System.out.print("Hgfhdssdgfadkhfdshkjhads");
                      }
                  }
          }
              System.out.println(greatestVal2 + " greatest month is: " + monthChosen);
      }
  }
  </code></pre>