int [] ary={9,5,7,-4,3,-2,10}; for (int i=0;i<ary.length;i++) { for (int j=i+1;j<ary.length;j++) { if(ary[i]<ary[j]) { int temp=ary[i]; ary[i]=ary[j]; ary[j]=temp; } } } for (int i=0;i<ary.length;i++) { System.out.print(ary[i]+" "); }