Question: I need help with this java code for class. Create a new class ArraySwitch.java which will have the following methods and call them on sample
I need help with this java code for class.
Create a new class ArraySwitch.java which will have the following methods and call them on sample arrays from the main method.
1. Write a method that accepts an array as input parameter and returns a new array that is the reverse of the original array. The original array should remain the same.
Method signature: public static int [] reverse(int [] array)
2. Write a method that accepts an array as input parameter, and two integers representing a range. The method returns a new array that has only the elements that belong in the specified range. The original array should remain the same.
Method signature: public static int [] filterRange(int [] array, int lowelem, int highelem)
3. Write a method that accepts an array as input parameter and then switches the position of the elements next to each other grouped two by two (see example below). This should be done in place, i.e. you are not allowed to create new array.
Method signature: public static void swap(int [] array)
Example input: 1 2 3 4 5 6 7 8 9 0
output: 2 1 4 3 6 5 8 7 0 9
Example input: 8 9 65 76 3 1 2
output: 9 8 76 65 1 3 2
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
