title: BubbleSort Implementation
body: <p>I tried to make an implementation of bubble sort, but I am not sure whether it is correct or not. If you can give it a look and if it is a bubble sort and can be done in better way please don't be shy. Here is the code:</p>
  
  <pre><code>package Exercises;
  
  import java.util.*;
  
  public class BubbleSort_6_18 
  {
      public static void main(String[] args) 
      {
          Random generator = new Random();
  
          int[] list = new int[11];
          for(int i=0; i&lt;list.length; i++)
          {
              list[i] = generator.nextInt(10);
          }
  
          System.out.println("Original Random array: ");
          printArray(list);
  
          bubbleSort(list);
  
          System.out.println("\nAfter bubble sort: ");
          printArray(list);
      }
  
      public static void bubbleSort(int[] list)
      {
          for(int i=0; i&lt;list.length; i++)
          {
              for(int j=i + 1; j&lt;list.length; j++)
              {
                  if(list[i] &gt; list[j])
                  {
                      int temp = list[i];
                      list[i] = list[j];
                      list[j] = temp;
                  }
              }
  
          }
      }
  
      public static void printArray(int[] list)
      {
          for(int i=0; i&lt;list.length; i++)
          {
              System.out.print(list[i] + ", ");
          }
      }
  }
  </code></pre>