title: Trouble casting integer object to primitive type
body: <p>I'm trying to do this challenge on codewars : <a href="https://www.codewars.com/kata/554ca54ffa7d91b236000023/train/java" rel="nofollow noreferrer">https://www.codewars.com/kata/554ca54ffa7d91b236000023/train/java</a>
  I changed the original array into an arraylist, but then I have to use the values in arrayist to do some comparisons with primitive types. </p>
  
  <p>I tried to cast the Integer objects using (int) but there's still casting errors. When I tried to do (int)(arrList.get(j)).equals(current), it tells me boolean can't be converted to int. </p>
  
  <pre class="lang-java prettyprint-override"><code>import java.util.*;
  public class EnoughIsEnough {
  
      public static int[] deleteNth(int[] elements, int maxOccurrences) {
        ArrayList arrList = new ArrayList&lt;&gt;(Arrays.asList(elements));
      for (int i = 0; i &lt; arrList.size(); i++) {
        int current = (int)arrList.get(i);
        int occurrences = 1;
        for (int j = i + 1; j &lt; arrList.size(); j++) {
          if (arrList.get(j).equals(current) &amp;&amp; occurrences &gt;= maxOccurrences) {
            arrList.remove(j);
          } else if (arrList.get(j).equals(current)) {
            occurrences++;
          }
        }
      }
      int arr[] = new int[arrList.size()];
      for (int i = 0; i &lt; arrList.size(); i++) {
        arr[i] = (int) arrList.get(i);
      }
      return arr;
      }
  
  }
  </code></pre>
  
  <p>It compiled but the test shows : class [I cannot be cast to class java.lang.Integer ([I and java.lang.Integer are in module java.base of loader 'bootstrap')</p>