I tried to find the sum of any array by using the for loop but the i++ part ended up being the deadcode unreachable. I don't understand why?
public static int sum(int[] data) {
int sum = 0;
int i;
for (i = 0; i < data.length; i++) { //the i ++ is the deadcode
sum += data [i];
return sum;
}
return 0;
}