title: arraylist java counting runs of integers
body: <p>I am new to java and array lists. I am supposed to sort populate an array full of random integers, then if there is a run (multiples of the same number in a row), put ( ) around that run. 
  So if the random list is:</p>
  
  <p>2 3 4 5 5 5 5 6  7 7 9</p>
  
  <p>2 3 4 (5 5 5 5) 6 (7 7) 9</p>
  
  <p>This is what I have so far:</p>
  
  <pre><code>import java.util.*;
  
  class Run {
    public static void main (String [] args){
  
      Scanner m = new Scanner(System.in);
  
      System.out.print("Enter length wanted: ");
      int len = m.nextInt();
  
      System.out.print("Enter max number wanted: ");
      int max = m.nextInt();
      max = max -1;
  
     int[] x = new int[len]; 
     ArrayList&lt;String&gt; y = new ArrayList&lt;String&gt;();
  
     //Filling x with random numbers
     for(int i = 0; i&lt;len; i++){
  
      x[i] = ((int)(Math.random()*max)+1); 
  
     }
  
     System.out.println("Orginal Array: " + Arrays.toString(x));
  
  
     for(int i = 0; i&lt;=len-1; i++){
       if(x[i] == x[i++]){ //I just don't know how I am exactly supposed to sort this
  
       }else{
  
       }
  
    }
     //Array List with ()
     System.out.println("Runs labeled Array: " + y);
  
    }
  }
  </code></pre>