This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Wrapper Classes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Wrapper Classes" Watch "Wrapper Classes" New topic
Author

Wrapper Classes

Brett Delia
Greenhorn

Joined: Feb 22, 2001
Posts: 20
Some colleages and I were debating why the wrapper class that correspond with the primitive datatypes are immutable. I was hoping to get some feedback from this group as to why they are.

Thank in advance.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

The reason why I think they are immutable is because of the purpose of these classes. If what I had read was correct, the purpose of these wrapper classes is so that you can store primitive values in Vectors and such. Since they all take Objects, but not primitives, there needed to be a way to put the primitives in them. SO they made the Wrapper classes. I also think they are used for statci methods for converting primitive types around.
I know I use them specifically for these two purposes. I always have to convert between pimitive and String and back and forth all the time.
For EJB's I 100% recommend always using the Wrapper Classes to map to database fields, rather than primitives. It just makes things easier.
Thanks
Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
sanjays samadder
Greenhorn

Joined: Mar 30, 2001
Posts: 24
hi,
if you have done any bit of awt class you will notice that textcomponets take in dta in string format .the question is how will you convert them to primitive so as to perform calculations on them .in order to make them as primitive data type wrapper classes are used.that is one practical use i have found.
thanks
sanjay
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Wrapper Classes
 
Similar Threads
wrapper class
Fitler and Wrapper
Weird Behaviour of List.contains()
user defined wrapper class
Ques on intern