title: Read array user input using methods (Java)
body: <p>So I have to write some code that has a user input the highest temperatures for each day of the week and a method to find the hottest day (highest integer) out of the array the user has inputted. The problem is how do I write the method so that it can read the user inputs?</p>
  <p>this is what the output should be:</p>
  <pre><code>Please enter the highest temperature of each day in a week (start with Sunday):
  25
  35
  15 
  34 
  21 
  25 
  23  
  The hottest temperature is 35
  </code></pre>
  <p>This is the code I have:</p>
  <pre><code>import java.util.Scanner;
  
  public class Main {
      private static int[] array;
  
      public static void main(String[] args){
  
        Scanner scanner = new Scanner(System.in);
  
        int array[] = new int[7];
        System.out.println(&quot;Please enter the highest temperature of each day in a week (start with Sunday): &quot;);
        for(int i = 0; i &lt; 7; i++){
  
            array[i] = scanner.nextInt();
  
            getHottest(array[i]);
            
        }
      }
  
          public static void getHottest(){
  
              int max;
  
              max = array[0];
              for(int i = 0; i &lt; 5; i++)
              {
                  if(max &lt; array[i])
                  {
                      max = array[i];
                  }
              }
              System.out.println(&quot;The hottest temperature is &quot; + max + &quot; degrees&quot;);
      
          }
       
    }
  </code></pre>