Wednesday, March 4, 2009

WikiAnswers - What are wrapper classes

WikiAnswers - What are wrapper classes: "Wrapper classes are classes that are used to make primitive variables into objects, and to make wrapped objects into primitives. int, boolean, double are all primitive data types and their respective wrapper classes are Integer, Boolean, and Double. Wrapper classes are useful in storing primitive data types in higher level data structures such as Stack, List, Queue, since primitives cannot be directly placed in these data structures they must be boxed in the wrapper classes. But, here's the good news, with the new Java 5.0, there is no need no worry about wrapper classes and boxing and unboxing (unless it's something taught in class), since there is auto-boxing and unboxing, therefore, one can directly 'add' primitives to a data structure and let the JVM do the rest."

No comments:

Post a Comment