Using JAVA please help me with this Given the following meth
Using JAVA please help me with this!
Given the following method header, give the code for the function using a binary search of an array. Don\'t worry about the precondition (assume this is already true). public static boolean has 10 (int[] data, int start, int end)//Precondition: The elements data[start] ...data[end] are sorted from smallest to largest. This//array segment might be empty (indicated by end being less than start).//Postcondition: A true return value indicates that the number 10 appears in the array//data[start]...data[end]. A false return value indicates that 10 doesn\'t appear ISolution
public class BinarySearch {
public static void main(String args[]) {
 int start, end;
 int[] data = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};// for testting the code i created this array
 // you can replace your array genetarion code in this code
end = data.length - 1;
 start = 0;
 boolean b = bs.has10(data, start, end);
 if (b) {
 System.out.println(\"the presece of 10th in the array is :\" + b);
 } else {
 System.out.println(\"the presece of 10th in the array is :\" + b);
 }
 }
 }
class bs {
public static boolean has10(int[] b, int start, int end) {
 int middle = (start + end) / 2;
 while (start <= end) {
 if (b[middle] < 10) {
 start = middle + 1;
 } else if (b[middle] == 10) {
 return true;
 } else {
 end = middle - 1;
 }
middle = (start + end) / 2;
 }
 if (start > end) {
 return false;
 }
 return false;
 }
 }

