Implementation of binary search algorithm in Java