Descending Order Program Using Java

Introduction

 
In this blog, I will explain about Descending order (Number) program, using Java. It is very simple in Java programming. The output will be displayed in the Run module. 
 

Software Requirement

 
JDK1.3.
 
Simple program
  1. import java.io.*;  
  2. class dsc {  
  3.  public static void main(String arg[]) {  
  4.   int i, j, t;  
  5.   int a[] = {  
  6.    4,  
  7.    2,  
  8.    1,  
  9.    5,  
  10.    8  
  11.   };  
  12.   for (i = 0; i <= a.length; i++) {  
  13.    for (j = i + 1; j <= a.length - 1; j++) {  
  14.     if (a[i] < a[j]) {  
  15.      t = a[i];  
  16.      a[i] = a[j];  
  17.      a[j] = t;  
  18.     }  
  19.    }  
  20.   }  
  21.   for (i = 0; i < 10; i++) {  
  22.    System.out.println(+a[i] + "\n");  
  23.   }  
  24.  }  
  25. }   
Explanation
 
In this blog, I will explain about the descending order (numbers) program, using Java. The output will be displayed in the Run module.
 
Output
 
k