Question: Write a java program that calls a method called reverse4 that accepts an ArrayList of integer values as a parameter and reverses each successive sequence

Write a java program that calls a method called reverse4 that accepts an

ArrayList of integer values as a parameter and reverses each successive sequence of four values in the list. If the list has extra values that are not part of a sequence of four, those values are unchanged. For example if a list stores values [10, 13, 2, 8, 7, 90, -1, 2, 4, 5], after the call the list should store the values [8, 2, 13, 10, 2, -1, 90, 7, 4, 5]. The first sequence of four (10, 13, 2, 8) has been reversed to (8, 2, 13, 10). The second sequence (7, 90, -1, 2) has been reversed to (2, -1, 90, 7) and so on. Notice that 4 and5 are unchanged because they were not part of a sequence of four values. Print the array before the call and after the call.

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!