title: Find the largest sequence of numbers in an integer arraylist
body: <p>This is what I've gotten so far. What I've tried to do is go through and find the sequence using greater or equals too in an if statement. Then when that value no longer is greater or equal to the preveious number it goes into the else statement which records that sequence number and resets it so the count can begin again. All these sequence values are saved in an arraylist so that when I'm all done I can just do a simple comparison to find the greatest sequence number and return that. I need help with my first if/else statement that gathers the sequence data because I'm pretty sure this is where my issues are happening. </p>
  
  <pre><code>public class LongestSequence {
  
      public static int getMaxSequence(ArrayList&lt;Integer&gt; list) {
          int sequence = 0;
          ArrayList&lt;Integer&gt; temp = new ArrayList&lt;Integer&gt;();
  
          for (int i = 0; i &lt; list.size() - 1; i++) {
              //this is where things go wrong. I think.
              if (list.get(i + 1) &gt;= list.get(i)) {
                  sequence++;
              } else {
                  //record the number in your arraylist
                  temp.add(sequence);
                  //reset count to 0
                   sequence = 0;
              }
           }
  
          int greatestnum = 0;
  
          for (int i = 0; i &lt; temp.size() - 1; i++) {
              if (temp.get(i) &lt; temp.get(i + 1)) {
                  greatestnum = temp.get(i + 1);
              } else {
                  greatestnum = temp.get(i);
              }
          }
          return greatestnum;
      }
  </code></pre>