Guest User

Untitled

a guest
May 21st, 2018
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. public class BubbleSort {
  2.  
  3. private static void bubbleSort(int[] intArray) {
  4. int n = intArray.length;
  5. int temp = 0;
  6.  
  7. for(int i=0; i < n; i++){
  8. for(int j=1; j < (n-i); j++){
  9.  
  10. if(intArray[j-1] > intArray[j]){
  11. //swap the elements!
  12. temp = intArray[j-1];
  13. intArray[j-1] = intArray[j];
  14. intArray[j] = temp;
  15. }
  16.  
  17. }
  18. }
  19.  
  20. }
  21. }
Add Comment
Please, Sign In to add comment