title: How do I print the last values of an ArrayList that aren't part of a successive sequence of four values?
body: <p>I am a beginner in Java. I was wondering how I would print the last couple of values for this reverse arrayList since they are not part of a successive sequence of 4. I was thinking of using if <code>(numbers.size()%4==0)</code> but I dont know where to properly implement it. </p>
  
  <hr>
  
  <pre><code>    import java.util.*;
      public class printArray {
  
      public static void main(String[] args) {
          ArrayList &lt;Integer&gt; numbers= new ArrayList&lt;&gt;();
          numbers.add(10);
          numbers.add(13);
          numbers.add(2);
          numbers.add(8);
          numbers.add(7);
          numbers.add(90);
          numbers.add(-1);
          numbers.add(2);
          numbers.add(4);
          numbers.add(5);
  
  
  
  
          System.out.println(numbers);
  
          System.out.println(reverse4(numbers));
  
      }
      public static ArrayList&lt;Integer&gt; reverse4 (ArrayList&lt;Integer&gt; numbers){
          ArrayList&lt; Integer&gt; reverseSet= new ArrayList&lt;&gt;();
              for (int i = 0; i &lt; numbers.size(); i += 4) {//goes from 0 to 4, 4 to 8 and keeps incrementing by 4
                  for (int k = i + 3; k &gt;= i ; k--)// reverse order, executes 4 times before going to the outer loop
               reverseSet.add(numbers.get(k));
  
  
          }
  
          return reverseSet;  
  
      }
  }
  </code></pre>