Question: a. Show the Java code (just the loops complete Java methods are not necessary): Write a loop that reads 10 strings (assume you have a

a. Show the Java code (just the loops complete Java methods are not necessary): Write a loop that reads 10 strings (assume you have a scanner object named "in" to read strings from the keyboard) and inserts them into an ArrayList (not an array). Write a second loop that prints out the strings in the opposite order from which they were entered.

b. Write a loop that checks whether two integer arrays, a[] and b[], have the same values in the same order, and print a message if a difference is found. Assume both arrays are of the same length.

c. Rewrite the following for loop using the for each construct to add each element from the data array to the sum. The data[] array is an array of values of type double.

for (i = 0; i < data.length; i++) sum += data[i];

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!