Java Programs

Write a Java Program to sort the numbers?


/* Java Program to sort the numbers */
public class SortNumbers {

     public static void main(String[] args) {      
         int[] number = {23,45,36,44,90}; /* give in put array here*/
         int temp;
         for (int i =0; i<number.length ; ++i){
             for (int j = i + 1; j < number.length; ++j){
                 if (number[i] > number[j]){
                     temp =  number[i];
                     number[i] = number[j];
                     number[j] = temp;
                 }
             }
         }      
         System.out.println("Sotered array : ");
         for(int i=0; i<number.length;i++){
                System.out.print(number[i]+ " ");
         }            
     }
}
www.000webhost.com