• 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

String a Wrapper Class

 
Ranch Hand
Posts: 425
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

It may seem a bit awkward but just wanted to know whether String Class is a wrapper class as it also wraps the characters which are primitive type. Okay can somebody tell me what exactly are wrapper classes ?

Thanks,
Rahul Juneja
 
Ranch Hand
Posts: 8945
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
wrapper classes wrap primitives. For e.g. Integer wraps int,
Character wraps char. String is a sequnce of characters and does not wrap primitives.
 
Ranch Hand
Posts: 1312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Java wrappers are classes that wrap up primitive values in classes that offer utility methods to manipulate the values. If for example you want to store a set of int values in the elements of a Vector, the values in a Vector must be objects and not primitives. When you want to retrieve the values wrapped up in the Integers that are in the Vector elements you will need to cast the elements back to Integers and then call the toxxValue in order to get back the original number. The following code demonstrates this technique.


The wrapper classes also offer utility methods for converting to and from the int values they represent. Thus if you have a string that could also represent a number, you can use a wrapper class to perform that calculation.
The methods of the wrapper classes are all static so you can use them without creating an instance of the matching wrapper
 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Pradeep,

Thats tha same i was trying to say him yday. Wrapper classer just wrap primitive data types.

Thanks
 
Rahul Juneja
Ranch Hand
Posts: 425
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks everybody. I understood ur poimnt guys. Can the Bartender or sheriff Please close this Topic.

Thanks,
Rahul Juneja
 
reply
    Bookmark Topic Watch Topic
  • New Topic