• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Why Wrapper Classes Are Needed in Java  RSS feed

 
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Wrapper classes Are Used To Acess Primitive Types as Objects,But Why We Would like to AcessPrimitive types to be accessed as Objects,Any one Can Tell me The Reason
 
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One reason is that you can't store primitive types in any of the Collection classes.
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wrapper classes are a way of manipulating the values stored in a primitive data type, and then treating those values as if they were an object. All of the Wrapper classes have methods that interact with each particular primitive data type.
 
Ranch Hand
Posts: 1282
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by sirisha makkapati:
Hi,
Wrapper classes Are Used To Acess Primitive Types as Objects,But Why We Would like to AcessPrimitive types to be accessed as Objects,Any one Can Tell me The Reason


I think, correctly, your question is better addressed by looking at earlier work in computer science, but the answer to your question is difficult to put into words while staying entirely within the Java nomenclature.

Originally, a value stored in memory would have to be read into a working area of the processor. Then, as compiler science kept up with more powerfull machines, it became simpler to use a record of where the value was stored rather than the value it's self. Then, something called the structure - which is remakably close to a class in Java - became used to keep several values in one ... object ... get it ?

A structure was used so often to keep all data in one place that it was boosted in capabilities and renamed the class, because all data could be classified into ojects which lend themselves to thinking.

They way compilers were written and the complexity of keeping up with everything just lead to keeping everyting in objects to make matters simple.
[ January 07, 2007: Message edited by: Nicholas Jordan ]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!