| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 
 | package com.coral.learning.alg.udemo.algorithms.sort;
 
 
 
 
 
 
 
 public class BubbleSort implements Sort {
 public static void main(String[] args) {
 int[] numbers = {34, 12, 23, 56, 56, 56, 78};
 BubbleSort bubbleSort = new BubbleSort();
 System.out.println("BubbleSort");
 bubbleSort.sort(numbers);
 
 }
 
 
 @Override
 public void sort(int[] arr) {
 
 for (int i = 0; i < arr.length; i++) {
 for (int j = 0; j < arr.length - i - 1; j++) {
 print(arr);
 if (arr[j] > arr[j + 1]) {
 swap(arr, j, j + 1);
 }
 }
 }
 }
 
 }
 
 |