1. Engineering
  2. Computer Science
  3. 10 reversing the elements of an array involves exchanging the...

Question: 10 reversing the elements of an array involves exchanging the...

Question details

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.
Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution