Question: java Write an array method to carry out each of the following tasks for an array of integers: a) Swap the first and last elements
Write an array method to carry out each of the following tasks for an array of integers: a) Swap the first and last elements in the array. b) Shift all elements by one to the right and move the last element into the first position. For example, 1 4 9 16 25 would be transformed into 25 1 4 9 16. c) Replace all even elements with 0. d) Replace each element except the first and last by the larger of its two neighbors. e) Move all even elements to the front, otherwise preserving the order of the elements. E.g., if the list contains 1, 2, 3, 4, 5, 6, 7, 8, 9, 0. The method returns the values rearranged as 2, 4, 6, 8, 0, 3, 7, 1, 9,5. f) Return true if the array contains duplicate elements (which need not be adjacent)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
