Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed
(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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

2. How important is informality in conversations?

Answered: 1 week ago