Am unable to pass: In the main(String[]) method, use a call to the Arrays.binarySearch(int[], int) method.
I believe I am calling the correct method within main. Can anybody help me understand why?
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[] sorted = Arrays.copyOfRange(array,0,array.length);
Arrays.sort(sorted);
int i = Arrays.binarySearch(sorted, element);
if(i<0)
System.out.println("false");
else
System.out.println("true");
}
}
Help with: Is anyone there? Java Syntax Zero Level 6, Lesson 8
Comments (1)
- Popular
- New
- Old
You must be signed in to leave a comment
Pavel281185 Backend Developer
6 June, 11:29
Please write name of Task to find it. Thx
0