Java Blog

 
 
 
 public class JAVA_037
 {


    public static void main(String[] args)
    {
       int[] array={10,-1,28,13,44,5,36,97,-18,11};

       System.out.println(\" The contents of the Array in original order are :\");

       for(int i=0;i<array.length;i++)
          System.out.println(\"\\t\\t\\t\\t\\t Array[\" + i + \"] = \" + array[i]);

       for(int j=0;j<(array.length-1);j++)
       {
          for(int k=0;k<(array.length-1);k++)
          {
             if(array[k]>array[(k+1)])
             {
                int temp=array[k];

                array[k]=array[(k+1)];
                array[(k+1)]=temp;
             }
          }
       }

       System.out.println(\"\\n The contents of the Array after sorting are :\");

       for(int l=0;l<array.length;l++)
          System.out.println(\"\\t\\t\\t\\t\\t Array[\" + l + \"] = \" + array[l]);
    }
 }

 
 
Didn't find what you were looking for? Find more on Program to sort the contents of an array using Bubble Sort