Question: Task 1: Reverse the elements of a character array Given a character array called charArray, write a Java method that takes this input array as
Task 1: Reverse the elements of a character array Given a character array called charArray, write a Java method that takes this input array as an argument, and returns a character array having all elements in charArray reversed. For example, when charArray = [H, e, l, l, o], the output will be: [o, l, l, e, H]. For this task you must not use any additional space, which means that you cant move the elements to another array in reverse order and then return that array. Hint: Make use of the two pointers technique and keep swapping elements at the two pointers. Provide your code in text format inside the pdf file so that I can test it. Also the method header should be like this: public static void reverseElements(char[] charArray) { // Write your code here }
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
