aspose file tools*
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 Spring in Action this week in the Spring 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: 14272
    
  21

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 8 API documentation
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: clarify my doubt