Menu

Picture Showing Error Experiencing Code Know M Missing Something Easy Code Picture Public Q43901984

This picture is showing the error I am experiencing with thiscode below it. I know I’m missing something easy.

----GRASP wedge2: working directory is [C:UserscaughDesktop]. ----GRASP wedge2: actual command sent [E:jGRASPbundled ja

CODE FOR ABOVE PICTURE:

public class CheckstyleLab
{
   private static final int arrSize = 10;

      public static void main(String[]args)
   {
      int[]squares = newint[arrSize];
    
      for (int i = 0; i < 10;i++)
      {
         squares[i] = (int)Math.pow(i, 2);
        System.out.printf(“Square of %d is %dn”, i + 1, squares[i]);
      }
    
      System.out.printf(“The Sum of theSquares is %d!nn”, sumArray(squares));

   }
     public static int sumArray(int[]arr)
   {
      int sum = 0;
      for (int i = 1; i <= arr.length;i++)
      {
         sum +=arr[i];
      }
      return sum;
   }

}

—-GRASP wedge2: working directory is [C:UserscaughDesktop]. —-GRASP wedge2: actual command sent [“E:jGRASPbundled javabinjava.EXE” CheckstyleLab]. —-GRASP wedge2: pid for process is 10688. Square of 1 is 0 Square of 2 is 1 Square of 3 is 4 Square of 4 is 9 Square of 5 is 16 Square of 6 is 25 Square of 7 is 36 Square of 8 is 49 Square of 9 is 64 Square of 10 is 81 Exception in thread “main” java.lang. ArrayIndexOutOfBounds Exception: Index 10 out of bounds for length 10 at CheckstyleLab.sumArray (CheckstyleLab.java:37) at CheckstyleLab.main(CheckstyleLab.java:27) Show transcribed image text —-GRASP wedge2: working directory is [C:UserscaughDesktop]. —-GRASP wedge2: actual command sent [“E:jGRASPbundled javabinjava.EXE” CheckstyleLab]. —-GRASP wedge2: pid for process is 10688. Square of 1 is 0 Square of 2 is 1 Square of 3 is 4 Square of 4 is 9 Square of 5 is 16 Square of 6 is 25 Square of 7 is 36 Square of 8 is 49 Square of 9 is 64 Square of 10 is 81 Exception in thread “main” java.lang. ArrayIndexOutOfBounds Exception: Index 10 out of bounds for length 10 at CheckstyleLab.sumArray (CheckstyleLab.java:37) at CheckstyleLab.main(CheckstyleLab.java:27)

Expert Answer


Answer to This picture is showing the error I am experiencing with this code below it. I know I’m missing something easy. CODE FOR…

OR