title: How to group an array?
body: <p>I am to make a code that:</p>
  <ol>
  <li>Ask the user for the array size</li>
  <li>Ask the user for integers</li>
  <li>The program reverses the integers and group them.</li>
  </ol>
  <p>I have already made a working code. My only problem is that I don't know how to group them. Can you help me?</p>
  <p><strong>Ex1:
  Input:</strong></p>
  <pre><code>5
  
  8
  
  2
  
  3
  
  7
  
  5
  </code></pre>
  <p><strong>Output:</strong></p>
  <pre><code>[5,7]-[3]-[2,8]
  </code></pre>
  <p>This is my code:</p>
  <pre><code>import java.util.Scanner;
  class Main{
  public static void main(String args[]){
      Scanner input= new Scanner (System.in);
      System.out.println(&quot;Enter size&quot;);
      int my_array = input.nextInt();
      System.out.println(&quot;Enter numbers to reverse&quot;);
      int[] intArray =new int[my_array];
  
  for(int i=0;i&lt;intArray.length;i++)
      {
          intArray[i]=input.nextInt();
      }
       for(int i=intArray.length-1;i&gt;=0;i--)
       System.out.println(intArray[i]);
  }
  }
      
  </code></pre>