title: Why isn't it an error?
body: <p>The following program is a recursive program to find the maximum and minimum of an array.(I think! Please tell me if it is not a valid recursive program. Though there are easier ways to find the maximum and minimum in the array, I'm doing in the recursive manner only as a part of a exercise!)</p>
  
  <p>This program works correctly and produces the outputs as expected.</p>
  
  <p>In the comment line where I have marked "Doubt here!", I am unable to understand why an error is not given during compilation. The return type is clearly an integer array (as specified in the method definition), but I have not assigned the returned data to any integer array, but the program still works. I was expecting an error during compilation if I did it this way, but it worked. If someone would help me figure this out, it'd be helpful! :)</p>
  
  <pre><code>import java.io.*;
  class MaxMin_Recursive
  {
      static int i=0,max=-999,min=999;
      public static void main(String[] args) throws IOException
      {
          BufferedReader B = new BufferedReader(new InputStreamReader(System.in));
          int[] inp = new int[6];
          System.out.println("Enter a maximum of 6 numbers..");
          for(int i=0;i&lt;6;i++)
              inp[i] = Integer.parseInt(B.readLine());
          int[] numbers_displayed = new int[2];
          numbers_displayed = RecursiveMinMax(inp);
          System.out.println("The maximum of all numbers is "+numbers_displayed[0]);
          System.out.println("The minimum of all numbers is "+numbers_displayed[1]);
      }
      static int[] RecursiveMinMax(int[] inp_arr)     //remember to specify that the return type is an integer array 
      {   
          int[] retArray = new int[2];
          if(i&lt;inp_arr.length)
              {
                  if(max&lt;inp_arr[i])
                      max = inp_arr[i];
                  if(min&gt;inp_arr[i])
                      min = inp_arr[i];
                  i++;
                  RecursiveMinMax(inp_arr);       //Doubt here!
              }
          retArray[0] = max;
          retArray[1] = min;
          return retArray;
      }
  }
  </code></pre>