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 The Software Craftsman this week in the Agile forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "clarify my doubt" Watch "clarify my doubt" New topic

clarify my doubt

karthik. G gopalan

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: 14669

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
Have you tried LearnNowOnline?
subject: clarify my doubt