• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Wrapper Classes

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic