public class b2 { public static void main(String args[]) { int a[] = {9,1,2,3,5,0,7,8,4,6}; int max, min, i, j; /* for(max = min = a[0], i = 1; i < a.length ; i++) { if(a[i] > max) max = a[i]; if(a[i] < min) min = a[i]; }*/ for(i = 0; i < a.length; i++) { for(j = i+1; j < a.length; j++) { if(a[i] > a[j]) { int temp = a[i]; a[i] = a[j]; a[j] = temp; } } } for(i = 0; i < a.length; i++) System.out.print(a[i]+" "); System.out.println(""); System.out.println("min = "+ a[0]); System.out.println("max = "+ a[a.length - 1]); } }