Binary Search Help

I did the program of Binary Search but got stuck somewhere...Please Help me on this.

Code :

class BinarySearch { public static void main(String[] args) { int data[] = {9,11,23,43,54,66,76,78,99}; int beg = data[0]; int end = data[data.length-1]; int mid = (int)((end-beg)/2); int item = 78; int loc = 0; do { if(item<data[mid]) { end = mid-1; } else beg = mid+1; mid = (int)((end-beg)/2); } while(beg<=end && data[mid]!=item); if(data[mid]==item) System.out.println("Successful"); else System.out.println("Unsuccessful"); } }