File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes What is a Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "What is a "wrapper" class" Watch "What is a "wrapper" class" New topic
Author

What is a "wrapper" class

Thomas Markl
Ranch Hand

Joined: Mar 08, 2001
Posts: 192
Can anybody explain what a wrapper class is and how we use it?
Thanks.
Thomas
Sayed Ibrahim Hashimi
Ranch Hand

Joined: May 17, 2001
Posts: 148
A wrapper class is a class that serves the sole purpose of holding something and adding some functionality to it.
In Java since the primitaves (like ints,floats,chars...) are not objects so if you want to treat them like one then you have to put use a wrapper class.
So lets say that i want to create a Vector of ints, the problem is a Vector only holds Objects not primitives. So what I will do is put all the ints in an Integer wrapper and use that. Example:

Hope this clears up some issues you are having.


SCJP 1.4<br /><a href="http://www.cise.ufl.edu/~sih" target="_blank" rel="nofollow">www.cise.ufl.edu/~sih</a>
Anthony Villanueva
Ranch Hand

Joined: Mar 22, 2002
Posts: 1055
Just to add... here's an example of a wrapper class: java.lang.Integer.
[ July 30, 2002: Message edited by: Anthony Villanueva ]
 
 
subject: What is a "wrapper" class
 
Similar Threads
@Wrapper class
wrapper classes
Usage of Wrapper Classes
@Wrapper class
Use of Wrapper class