title: Why is the value of array[d] 5?
body: <p>Im new to arrays... and i quite having a hard time understanding how arrays works in this CODE only...
  i am doing a bubble sort. the only thing i dont understand is that can the variable d be put in a variable array???</p>
  
  <pre><code>import java.util.Scanner;
  
     public class bubbleSort
    {
    public static void main(String []args)
    {
          int n, c, d, swap;
          Scanner in = new Scanner(System.in);
  
          System.out.print("Input number of integers to sort");
          n = in.nextInt();
  
          int array[] = new int[n];
  
          System.out.println("Enter " + n + " integers");
  
          for (c = 0; c &lt; n; c++)
            array[c] = in.nextInt();
  
          for (c = 0; c &lt; ( n - 1 ); c++)
          {
                for (d = 0; d &lt; n - c - 1; d++)
                {
                  if (array[d] &gt; array[d+1])
                  {
                      System.out.println("array d:" + array[d]); // value is 5
                    swap       = array[d];
                    array[d]   = array[d+1];
                    array[d+1] = swap;
                  }
               }
          }
  
          System.out.println("Sorted list of numbers");
  
          for (c = 0; c &lt; n; c++)
            System.out.println(array[c]);
  }
  }
  </code></pre>