title: how to print subsets of 3 in java?
body: <p>I am doing a course offered by my college and facing problem in one of the code challenges.</p>
  
  <p><strong>The question is:</strong>
  Write a Java code to print all subsets of size 3.</p>
  
  <p><em>Sample Input:</em></p>
  
  <pre><code>arr_size = 5
  
  arr[] = {1, 7, 3, 4, 9}
  </code></pre>
  
  <p><em>Sample Output:</em></p>
  
  <pre><code>(1, 7, 3) (1, 7, 4) (1, 7, 9) (1, 3, 4) (1, 3, 9) (1, 4, 9)
  
  (7, 3, 4) (7, 3, 9) (7, 4, 9)
  
  (3, 4, 9)
  </code></pre>
  
  <p><strong>The code I wrote for this:</strong></p>
  
  <pre><code>import java.util.Scanner;
  class Main{
      public static void main(String args[]) {
         // Type your code here
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int a[] = new int[n];
        for(int i=0; i&lt;n;i++)
          a[i] = in.nextInt();
        for(int i=0;i&lt;n;i++)
        {
          for(int j=i+1;j&lt;n;j++)
          {
            for(int k = j+1; k&lt;n; k++)
            {
              System.out.print("(" + a[i] + ", " + a[j] + ", " + a[k] + ") ");
  
            }
          }
          if(i&lt;2)
            System.out.print("\n");
        }
      }
  }
  </code></pre>
  
  <p>My output matches with the expected output but the website shows wrong. I don't know where I went wrong. Can anybody help me??</p>
  
  <p>Here is the screenshot of my output and expected output:
  <img src="https://i.stack.imgur.com/z6tJD.png" alt=""></p>
  
  <p><img src="https://i.stack.imgur.com/RUzfn.png" alt=""></p>