when the value not contained inside array...the index result will become negative ..that's means false...I have tried but the third task requirement still wrong...
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[] array = {9, 8, 7, 6, 5, 4, 3, 2, 1};
Arrays.sort(array) ;
if(Arrays.binarySearch(array,5)>=0)
{
System.out.println("true");
}
else { System.out.println("false");}
}
}