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 diffrences in definiotiones question.. 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 "diffrences in definiotiones question.." Watch "diffrences in definiotiones question.." New topic
Author

diffrences in definiotiones question..

johny doe
Ranch Hand

Joined: Dec 07, 2007
Posts: 78
what is the difference between
when i define variable as
int

and

integer

what is the differnce between the two??
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

Java has two kinds of data types: primitive types and non-primitive types.

int is a primitive type (a 32-bit signed integer), and Integer is a class. An int is much more lightweight than an Integer. You should use int, unless there's a reason that you need an object instead of a primitive type.

For more info:
The Java Tutorial - Primitive Data Types
The Java Tutorial - Object-Oriented Programming Concepts


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: diffrences in definiotiones question..
 
Similar Threads
Zachman Certification
compare object
JRE vrs. JVM
Quick Question HttpSessionBinding vs HttpSessionAttribute Listeners
Run as AWT or SWT Application Eclipse Question