Advertisement
ultravibez

Untitled

Sep 2nd, 2017
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.49 KB | None | 0 0
  1.     public static void main(String[] args) {
  2.     int[] arr = {4, 7, 5, 6, 2};
  3.     System.out.println(determineGreatestNum(arr, 0, arr[0]));
  4.     }    
  5.  
  6. static public int determineGreatestNum(int[] arr, int index, int currentGreatest){
  7.  
  8.         if (index == arr.length)
  9.             return currentGreatest;
  10.  
  11.         if (arr[index] > currentGreatest)
  12.             currentGreatest = arr[index];
  13.  
  14.         index += 1;
  15.         return determineGreatestNum(arr, index, currentGreatest);
  16.     }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement