Copy the array range

Report a typo

Use the Arrays.copyOfRange() method to copy the given array within the specified range. Range values should pass by the Scanner input. In the end, you must print the new array.

Sample Input 1:

7 9 11 13
2 4

Sample Output 1:

[11, 13]
Write a program in Java 17
import java.util.Scanner;
import java.util.Arrays;

public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int[] arr = {scanner.nextInt(), scanner.nextInt(), scanner.nextInt(), scanner.nextInt()};
int[] newArr = // write your code here

System.out.println(/* Print the new array here */);
}
}
___

Create a free account to access the full topic