All Questions
3 questions
3
votes
4
answers
701
views
Why is ArrayList not a Stack
I've been wondering for a while why an ArrayList does not have a stack-like interface (think push() and pop())
I frequently find myself using these constructs in Java:
list.get(list.size() - 1);
list....
5
votes
2
answers
5k
views
Why does java collections not supply a function for the index of max value?
I have been using Collections.max(list) for many projects, but I occasionally want to find the index of that maximum element. I feel silly writing a function to do this for myself in every program I ...
43
votes
8
answers
154k
views
Why does java.util.ArrayList allow to add null?
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 ...