View Single Post
  #2 (permalink)  
Old 12-03-2007, 02:08 AM
hardwired hardwired is offline
Senior Member
 
Join Date: Jul 2007
Posts: 1,146
hardwired is on a distinguished road
Code:
import java.util.Arrays; ... int[] n = { 3, 7, 4, 6, 5 }; int max = -Integer.MAX_VALUE; for(int j = 0; j < n.length; j++) { if(n[j] > max) max = n[j]; } System.out.println("loop max = " + max); System.out.println("original = " + Arrays.toString(n)); Arrays.sort(n); System.out.println("sorted n = " + Arrays.toString(n)); System.out.println("sorted max = " + n[n.length-1]);
Reply With Quote