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
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started