Win a copy of Getting started with Java programming language this week in the Beginning Java forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

use of wrapper class  RSS feed

 
Amirtharaj Chinnaraj
Ranch Hand
Posts: 241
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi folks

i want to know the purpose of wrapper class in java

looking for your replies

regards
amir
 
jayalal jayarathna
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
wrapper class are there to bring object behaviour to primitives.
 
Campbell Ritchie
Sheriff
Posts: 53595
127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wrapper classes also provide methods which manipulate or investigate primitives, eg "toBinaryString()", "isJavaIdentifierPart()" and some data eg MAX_VALUE.
Look up the wrapper classes in the API: Boolean, Byte, Character, Double, Float, Long, Integer, Number, Short. I think it unfortunate that two wrapper classes have different names from their primitive counterparts. I have included Number since it is the cuperclass of several of the wrapper classes.
 
Amirtharaj Chinnaraj
Ranch Hand
Posts: 241
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
when and where the necessities will be arised

to represent a primitive type as an object

apart from putting primitive type objects in a collection

regards
amir
 
Srikanth Ramu
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In Wrapper class you will find several utility methods for eg: Integer has method to convert an int to a String and a String to an int etc, Character has methods to change the cases, check for digits, identify spaces etc
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!