I guess I have a fairly simple question. I have two double arrays and a hash map.
double[] x
double[] y
HashMap<Integer, HashSet<Integer>> myList;
I'd like to get the values for each key and find a summation by using those values in two arrays. However, I keep receiving the scope error. "...defined in an enclosing scope must be final or effectively final"
for (int i = 0; i < size; i++) {
if ( .... ) {
double sum = 0;
myList.get(i).forEach((val) -> {
sum = sum + x[val] + y[val];
});
if (sum >= ...) {
}
}
I placed the variable sum
in different places, but could not figure out what I am doing wrong. Could someone help me with that?