title: Remove all occurrences of an integer from an int array
body: <p>How can I remove all occurrences of an integer, say, 17 in this example from a given array in java?
  I tried setting entries to (Integer) null though it doesn't work.</p>
  
  <p>Input array: <code>[0,6,0,17,1,9,17,8,4]</code></p>
  
  <p>Output array: <code>[0,6,0,1,9,8,4]</code></p>
  
  <pre><code>for(int i =0;i&lt;ansa.length;i++){
  if(ansa[i]==17)
        {
            ansa[i]=(Integer)null;
        }
  }
  </code></pre>
  
  <p>This results in</p>
  
  <pre><code>Exception in thread "main" java.lang.NullPointerException
  </code></pre>