Question: Given the declarations: int[] list = new int[10]; show the elements of the array list after the following statements are executed (exercises a, b, and

Given the declarations:

int[] list = new int[10];

show the elements of the array list after the following statements are executed (exercises a, b, and c are independent. All use the same declaration.)

a) for(int i = 0; i < list.length; i++)

list[i] = 10 - i;

b) for(int i = 0; i < list.length; i++){

if (i <= 4)

list[i] = -1;

else

list[i] = 1;

}

c) for(int i = 0; i < list.length; i++){

if(i % 2 == 0)

list[i] = i;

else

list[i] = i + 1;

}

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!