I'm trying to write a function that cycles through an integer array looking for zeros. It looks like this:
def fullIntArray(arr:Array[Int]): Boolean = {
var counter = 0;
for(a <- 1 to arr.length by 1){
if(arr(a) != 0){
counter += 1;
}
}
if(counter == arr.length){
return true;
}else{
return false;
}
}
I'm getting an ArrayIndexOutOfBoundsException
from
arr(a)
Can anyone explain why, or what I should do instead?