Question #59018

write a method to receive 3 parameters:
- an array of integer numbers
- an integer value : low
- an integer value : high
the method will create new array and copy all the value that are between low and high into new array. the method will return the new array upon completion

Expert's answer

package com.company;

import java.util.Arrays;

public class Main {

public static int [] copyArrayFromLowtoHigh(int [] arr, int low, int high){
int N = (high - low) + 1;
int [] result = new int[N];
for (int i = 0; i < N; i++){
result[i] = arr[low++];
}
return result;
}

public static void main(String[] args) {
int [] arr = {1, 3, 4, 56, 22, 11, 12, 45, 78, 32, 11};
System.out.println(Arrays.toString(copyArrayFromLowtoHigh(arr, 1, 4)));

// write your code here
}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

LATEST TUTORIALS
APPROVED BY CLIENTS