title: List all possible combinations
body: <p>Here's what I am trying to do: </p>
  
  <blockquote>
    <p>Given a list of names, print out all
    combinations of the names taken three
    at a time. If the list has too few
    elements, don't print anything. Names
    must occur in the same order that they
    appear in the list. So, if the list
    contains the names Kennedy, Johnson,
    Nixon, Ford, you program prints: </p>
    
    <p>[Kennedy, Johnson, Nixon]<br>
    [Kennedy,Johnson, Ford]<br>
    [Kennedy, Nixon, Ford]
    [Johnson, Nixon, Ford]   </p>
    
    <p>Put the values in an array and then use the
    Arrays.toString() method to print the
    results, one per line.</p>
    
    <p>Parameters: list - - a list of name.</p>
  </blockquote>
  
  <p>Right now I'm using print statements to see if I am on the right track, if I am, I'll finish adapting this into an array. </p>
  
  <p>Here's my code:</p>
  
  <pre><code>int x = 0;
   int y = 1; 
   int z = 2; 
  
  
   for(int i = 0; i&lt;list.length;i++){
  
    for (int j = 0;j&lt;3;j++){
  
     System.out.print(list[x]);
     System.out.print(list[y]);
     System.out.print(list[z]);
  
     if (j&gt;=1){y++;}
     if (z != list.length){z++;}
  
    }
    x++; 
  
   }
  </code></pre>
  
  <p>Here's the error I get: </p>
  
  <pre><code>Enter commands:
  trio Kennedy, Johnson, Nixon,ford
  Kennedyjava.lang.ArrayIndexOutOfBoundsException: 1
   at MyAssign1.trio(MyAssign1.java:204)
   at Assign1.processOneCommand(Assign1.java:109)
   at CmdInterpreter.processCommands(CmdInterpreter.java:198)
   at CmdInterpreter.processCommands(CmdInterpreter.java:230)
   at CmdInterpreter.ooMain(CmdInterpreter.java:243)
   at MyAssign1.main(MyAssign1.java:20)
  </code></pre>
  
  <p>Line 204 is: </p>
  
  <pre><code>System.out.print(list[y]);
  </code></pre>
  
  <p>What am I doing wrong? </p>