This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes clarify my doubt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "clarify my doubt" Watch "clarify my doubt" New topic
Author

clarify my doubt

karthik. G gopalan
Greenhorn

Joined: Oct 17, 2006
Posts: 5
what is the difference between using int and Integer types in java. and also tel me about the wrapper classes and why they are used.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

The data type "int" is a primitive type, and "Integer" is a class; it's a wrapper class for "int".

In Java, primitives are not objects. Sometimes that is inconvenient. For example, in collection classes such as ArrayList, Vector etc. you can only store objects. You can't store primitives in those collections. Wrapper classes are used to represent the primitive types as objects, so you can for example store them in a collection.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
 
jQuery in Action, 2nd edition
 
subject: clarify my doubt
 
Similar Threads
Splitig integers
Do you like twitter ?
Posting to bump up my count...
Constructing overloading
Loading an image