Question: 10. Reversing the elements of an array involves exchanging the corresponding elements of the array: the first with the last, the second with the next

 10. Reversing the elements of an array involves exchanging the corresponding

10. Reversing the elements of an array involves exchanging the corresponding elements of the array: the first with the last, the second with the next to the last, and so on, all the way to the middle of the array. For example, if the array has 4 elements: (80, 85, 95, 100), we want to reverse the elements so that the array becomes (100, 95, 85, 80) Given an array a, write a loop that reverses the elements of the array. You may declare questonal variables as needed. (For full credit, invoke one of the swap methods from 9 appropriately.) 11. Write a method that receives a String as a parameter, creates a new String that contains the same characters in the specified String but in reverse order, and returns that String. For example, if the String received as a parameter is "loop", the method should return "pool" Your method should work for any String. You will need to appropriately invoke the charAt method of the String class. Its description in the Java standard library is: char sharArint index) Returns the chac valoc at the specified index

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!