In Java, In general, some collection implementations allow null elements and some don’t.
Has it something to do with garbage collection?
In Java, In general, some collection implementations allow null elements and some don’t. Has
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In a broad sense I think it’s just basically up to the implementation to decide whether
nullcan be a valid element of the collection (‘logically’) or not. I really doubt there’s more to it although I could be proven wrong.Relevant bits from the documentation: