Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
Sort - BubbleSort.java

BubbleSort.java

Caricato da:
Scarica il programma completo

  1. /*
  2.  * To change this template, choose Tools | Templates
  3.  * and open the template in the editor.
  4.  */
  5.  
  6. package sort;
  7.  
  8. /**
  9.  *
  10.  * @author Paolo
  11.  */
  12. public class BubbleSort extends SortMethod{
  13.  
  14.     @Override
  15.     public Integer[] sort(Integer[] pArray) {
  16.         System.out.println("I'm a bubble sort!");
  17.         int swap;
  18.         for(int i=0; i<pArray.length; i++){
  19.             for(int j=0; j<pArray.length; j++){
  20.                 if(pArray[i]<pArray[j]){
  21.                     swap=pArray[i];
  22.                     pArray[i]=pArray[j];
  23.                     pArray[j]=swap;
  24.                 }
  25.             }
  26.         }
  27.         return pArray;
  28.     }
  29.  
  30. }