Question: Ok so I need to figure out this Array loop codes data input (so basically the index and the numbers in each number of the

Ok so I need to figure out this Array loop codes data input (so basically the index and the numbers in each number of the index)

public class Array-With-Loop3 {

public static void main(String [] args) {

int [] x = {-4, 9, 8, 2, -5, 7, 1};

int val = 0;

for(int i=1; i

val = val + x[i];

}

}

}

and me and my colleague have different answers I think the length of val is 22 while he thinks the length of val is 18. Since i=1 I think that it would just skip over the placement for 0 so all the values will tally up to 22 instead of 18 but if anyone can answer this question please help

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!