title: How to compare two arrays of different sizes?
body: <p>So my task is to read a file line by line and store the integers into an array. Then to add the integers in spots 1-5, 2-6, 3-7 etc. and store those into a new array. </p>
  
  <p>In array 1 there is 4 more values than array 2. I need to compare these Arrays and see if array1 is 0.999 bigger than array2. </p>
  
  <p>If it is indeed larger, I need to print out the LOCATION of the number in the array 1.</p>
  
  <p>Right now my problem is my code is outputting that every number is larger than the corresponding number in array 2.</p>
  
  <p>Code:</p>
  
  <pre><code>import java.io.*;
  import java.util.Arrays;
  import java.util.Scanner;
  
  public class Asgn7
  {
      public static void main(String[] args) throws FileNotFoundException
      {   
          Scanner file = new Scanner(new File("asgn7data.txt"));
          double[] array = new double[file.nextInt()];
          double[] newArray = new double[array.length - 4];
          double tempVal = 0;
          int j = 0;
          int count = 0;
  
          while(file.hasNext())
          {
          for(int i = 0; i &lt; array.length ; i++)
          {
              array[i] = file.nextInt();
          }
  
          for(j = 0; j &lt; array.length - 4; j++)
          {
              for(int k = 0; k &lt; 5; k++)
              {
                  newArray[j] += array[j+k] / 5;  
               }
  
          }
  
          for(int i = 2; i &lt; array.length; i++)
          {
              if(array[i] &gt; (newArray[i-2] + 0.999));
              {
                  count++;
                  tempVal = count;
              }
  
               System.out.println(tempVal);
          }   
          }
  
      }
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/b90Dt.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/b90Dt.png" alt="enter image description here"></a></p>
  
  <p>The values which should be compared are from 3-13.</p>