This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
While it's a good question why there are both Strings and Integers in this list, the Strings don't really seem to have anything to do with the actual question or its answer. If we simply ignore the strings, the whole thing seems to make more sense.
ravikumar latha wrote:You can remove the integers from arraylist by using remove method of iterator interface.
Or more conveniently in this case, there's a remove method on the ArrayList itself.
The problem here is that there are two remove() methods on List - a remove(Object), and a remove(int). If you use the remove(int), the int argument is taken to be the index. If you use remove(Object) it's taken to be the value. From the way krish describes the problem, we probably want to remove the value 10, not the 10th element. So we need to make sure that we use the Object version of remove():