• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

diffrences in definiotiones question..

 
johny doe
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15219
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic