0

My code is compiling but I am getting the following error: "Index 3 out of bounds for length 3". I will appreciate if someone can please help me understand what I did wrong.
import stdlib.StdOut;

public class Lista {
    public static void main(String[] args) {
        double x = {0.30, 0.50, 0.10};
        double y = {0.60, 0.10, 0.40};
        double sum = 0.0;
        for (int i = 0; i <= x.length; i++)
            for (int j = 0; j <= y.length; j++)
                sum += x[i] * y[j];
        StdOut.println(sum);
    }
}
C.Sanchez
  • 25
  • 1
  • 7
  • 4
    replace all your `<=` signs with ` – Alanpatchi Jun 15 '20 at 14:55
  • 1
    Does this answer your question? [What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it?](https://stackoverflow.com/questions/5554734/what-causes-a-java-lang-arrayindexoutofboundsexception-and-how-do-i-prevent-it) – andrewjames Jun 15 '20 at 14:57

0 Answers0