Home  |  Contact         

Zrinity is the leader in enterprise-class email marketing management solutions and content management solutions for marketing professionals and developers worldwide.
Products Services Solutions Support Resources Partners Company
Java, PHP, CF Code Samples

Use of Bubble Sort to sort numbers
Beginner Java Tutorial
JDBC Tutorial
Java Interview Questions

Code for Bubble Sort


import java.util.Random;

    public class BubbleSort{

       public static void main(String[] args){
          int[] values;
         values=new int[10];
         int temp;
         Random randNumber =   new Random();
      
          for(int i=0;i<10;i++){
             values[i] = randNumber.nextInt();
          }

//Bubble Sort Algorithm is used
         for (int i=0; i<10;i++) {
            for (int j=i+1; j < 10;j++){
                  if (values[i] > values[j]) {
                     temp = values[j];
                     values[i] = values[j];
                     values[j] = temp;
                     }
            }
         }

         for(int i =0; i <10; i++){
            System.out.println("The random values are "+values[i]);
            }
       }
                   
}


Regards,
Hemanth

Beginner Java Tutorial
JDBC Tutorial
Java Interview Questions


More Code Samples



  
home products services partners company support contact
Copyright 2006 © Zrinity Inc. All rights reserved.     View our privacy policy         September 7, 2010