package en.codegym.task.pro.task05.task0519;
import java.util.Arrays;
/*
Is anyone there?
*/
public class Solution {
public static int[] array = {9, 8, 7, 6, 5, 4, 3, 2, 1};
public static int element = 5;
public static void main(String[] args) {
//write your code here
int[] tmpArray = Arrays.copyOfRange(array, 0, array.length);
Arrays.sort(tmpArray);
int idx = Arrays.binarySearch(tmpArray, element);
boolean contained = idx >= 0;
System.out.println(contained);
}
}
error message: In the main(String[]) method, use a call to the Arrays.binarySearch(int[], int) method. Although i use Arrays.binarySearch(int[], int) ???
Resolved
Comments (3)
- Popular
- New
- Old
You must be signed in to leave a comment
Lisa L
20 June 2022, 15:50solution
have you tried copyOf instead of copyOfRange? I know the result is the same but sometimes CG requires some certain path to the solutionl
+5
Maksim Krasnov
20 June 2022, 18:27
Thank you.
The test passes.
+1
Guadalupe Gagnon
20 June 2022, 15:08
Looking at the comments on the task page it looks like this task is bugged.
+1