Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

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

Step: 3

blur-text-image

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

Oracle 10g SQL

Authors: Joan Casteel, Lannes Morris Murphy

1st Edition

141883629X, 9781418836290

More Books

Students also viewed these Databases questions