The AP Computer Science A exam likes to ask questions along the lines of this code pictured below:

The question is,.. what does the “mystery” method do to that input array ?…. What is the output ?
And the answer is… Scroll down a bit
1 |
1,4,5,1, |
Yes, this code does indeed successfully remove excludingMe from the array
Although this code does successfully remove all occurrences of excludingMe , the code is not very intuitive. And that’s that the sort of code that you will need to be able to figure out when you tackle some AP A computer science multiple choice questions. A more intuitive way to remove elements from an array is covered in this post.