On 11/30/2013 10:03 PM, Pavitra Gupta wrote:
An item of a collection has to be object type. Why does a collection can't take primitive type? Why was it designed this way?

The reason is if we allow primitive type in an collection, there is no way to know if it has been set or not. In other words, there is no value that can be used to
indicate if it is set or not.  (Note that 0 is valid int value.)

If requiring it to be Object type, we can check if it is null or not.

-S

--
You received this message because you are subscribed to the Google Groups "JPassion.com: Java Programming" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
Visit this group at http://groups.google.com/group/jpassion_java.
For more options, visit https://groups.google.com/groups/opt_out.


--
-------------------------------------------------------------------
             Sang Shin, [email protected]
  Founder and Chief Instructor of JPassion.com (JavaPassion.com)
         http://www.linkedin.com/in/javapassion (Linkedin)
          http://twitter.com/javapassion (Tweeter)
            Life is worth living... with Passion!
5-day Web Services programming codecamp: Dec. 9th-13th Practically Free 3 to 5 days Live, Hands-on, Online Codecamps on
 Java, HTML5, Ruby/Rails, Grails, JavaScript/jQuery, Spring, Android
             http://jpassion.com/codecamps
----------------------------------------------------------------------

--
You received this message because you are subscribed to the Google Groups 
"JPassion.com: Java Programming" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
Visit this group at http://groups.google.com/group/jpassion_java.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to