Question: (10 points) Write a method that take Hints: s. s an array of Object as parameter, and reverse the array . Declare the method as

 (10 points) Write a method that take Hints: s. s an

(10 points) Write a method that take Hints: s. s an array of Object as parameter, and reverse the array . Declare the method as static since we want to test this method by main method. Method main is static and can only call static methods directly We do not need to return anything, the change applies to the array parameter A possible way to reverse an array is to use two ends, one starts the other starts from the rightmost index, then we swap these two elements, afterwards, move the leftmost index one step to the right, index one step to the left, e from the leftmost index and move the rightmost continue the above procedure until both ends meet. You can use two indices, the left one starts from index 0, the right one starts from the last index. You can test your method with the following arrays: Integert) arr (1, 2, 3, 4) Doublet] arr2 (1.0, 2.1, 3.2, 4.0) String[] greetings = { "Hello", "How are you?", "What is up?" }; Here is the sample output: The original array: (1, 2, 3, 4) After reversion: [4, 3, 2, 1) The original array: 11.0, 2.1, 3.2, 4.0 After reversion: [4.0, 3.2, 2.1, 1.0] The original array: [Hello, How are you?, Nhat is up?) After reversion: [What is up?, How are you?, Hel1o]

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!