Advertisement
Guest User

Untitled

a guest
Aug 28th, 2014
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.44 KB | None | 0 0
  1. // Let us say we have an array called intArray[] with size 'n'
  2. // To find the largest integer in the array, we simply need to go through the entire array, and ask the question 'is this number greater // than my current greatest number?'
  3.  
  4. int currentMax = intArray[0]
  5.  
  6. for(int i=1; i < n; ++i){
  7.     if(intArray[i] > currentMax){
  8.         currentMax = intArray[i]
  9.     }  
  10. }
  11.  
  12. // After this for statement, the currentMax value is the maximum value of the array
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement