Search |
||
(Not So) Stupid Questions 20: Primitives and Collections
Tue, 2007-11-27
Editor's note: Sometimes the most interesting discussions begin when someone says, "This may be a stupid question, but ...." If the person asking the question has taken the time to think about the problem before asking, the question is often not stupid at all. The uncertainty points out an ambiguity in the specs, holes in the docs, or a search for how more experienced programmers might address a particular problem. From time to time, we will print one of the "(Not So) Stupid Questions" we receive and invite our readers to answer the question in the feedback section. Remember that new people are joining the Java community all the time and may be looking for help from those with more experience. Also, those who began with Java as their first language can benefit from those coming to the community with experience in other languages. As always, answer the questions with kindness. You are also welcome to submit your questions to This may be a stupid question, but ... "Can you really not use primitives in a collection?"First Thoughts In an attempt to understand boxing and unboxing, I was rooting around on the Java.sun.com site, and found the J2SE 5.0 page on Autoboxing. On the first line, it says:
So I tried testing it out with the following code:
Is there a reason I can input raw primitives into a collection without boxing them? »
Related Topics >>
Programming
Comments
Comments are listed in date ascending order (oldest first)
|
||
|