title: Picking different random elements from int array each time in iteration?
body: <p>I have an int vector such as <code>int[] A = {6, 1, 5, 3, 4, 2}</code> and I need to picking two different elements randomly during three steps, and each step should pike up different elements from other steps.</p>
  
  <p>For example:</p>
  
  <ol>
  <li>choose 2, 5</li>
  <li>choose 6, 3</li>
  <li>choose 4, 1</li>
  </ol>
  
  <p>I try to do it, but I failed many times. I will really appreciate for any help.
  here is my last code.</p>
  
  <pre><code>public class T8 {
      public static void main(String[] args) {
          int n=5,   d=2, r,  i,  j;
          int[] B = new int [d];
          Random rand=new Random(); 
          System.out.println("d = "+d);
          Integer[] A = {10,12,3,4,5};
          List&lt;Integer&gt; list = new ArrayList&lt;Integer&gt;(Arrays.asList(A));
          for(j=0; j&lt;d; j++){
              r = rand.nextInt(n);
              B[j] = A[r];
              System.out.print(B[j]+"   ");
              list.remove(r);
              A = list.toArray(new Integer[0]);
              n=n-1;
          }
  
          System.out.println("");
          for(j=0; j&lt;n; j++){
              System.out.print(A[j]+"   ");
          }
      }
  }
  </code></pre>