Why does java.util.ArrayList allow to add null?
- by Alfredo O
I wonder why java.util.ArrayList allows to add null. Is there any case where I would want to add null to an ArrayList?
I am asking this question because in a project we had a bug where some code was adding nulls to the List and it was hard to spot where the bug was. Obviously a NullPointerException was thrown but not until another code tried to…