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.   
  3. class dsc  
  4.  {  
  5.   public static void main (String arg[])  
  6.    {  
  7.      int i,j,t;  
  8.      int a[] = {4,2,1,5,8};  
  9.        
  10.      for(i=0;i<=a.length;i++)  
  11.       {  
  12.        for(j=i+1;j<=a.length-1;j++)  
  13.         {  
  14.          if(a[i] < a[j])  
  15.           {  
  16.               t = a[i];  
  17.               a[i] = a[j];  
  18.               a[j] = t;    
  19.           }  
  20.        }  
  21.      }  
  22.    for(i=0;i<10;i++)  
  23.     {  
  24.      System.out.println(+a[i]+"\n");  
  25.     }  
  26.   }  
  27.  }    
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

Ebook Download
View all
Learn
View all