Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Nicholas Brigham
780 PointsWhat is "wrapping"
They continue to use this term and I have no idea what it means. I just finished a college course (Intro to Java) and its lab, and this was never mentioned when speaking about objects, classes, methods, etc. I am wondering what it means, examples would be great, analogies, etc. Thank you so much in advance for the help and I hope I can answer questions in the future!
Simon Coates
28,695 PointsThe most obvious example is when you create an instance of a Integer class. Java provides primitive wrapper classes. The point is that they wrap a primitive in an object, to get object behaviour (eg. within generics). It's standard terminology and often comes up within a discussion of autoboxing. I'd assume when used generally, it probably means that the purpose of an object is to enclose/house some (single) specific thing.
update: see http://stackoverflow.com/questions/889160/what-is-a-wrapper-class .
Nino Roldan
Courses Plus Student 9,308 PointsNino Roldan
Courses Plus Student 9,308 PointsPerhaps you are referring to "encapsulation" e.g. methods and attributes of classes can only be seen if needed; "private", "public" etc..
Users of classes that we create would like to treat our classes as "blackboxes", meaning they want our class to do an operation but they are not interested in how to do it. This is where encapsulation comes in, we limit the access of our classes attributes because essentially, the Users are not interested in the workings of the class. But then again, you can expose the attributes of the class if you want your class to be repurposed for other tasks.
I am in no way an expert, just wanted to participate in your question and hopefully you could get an idea from it.