Answers for "long int vs int"

5

integer vs int

Int is a primitive data type
On the other hand Integer is a wrapper class that wraps a primitive type
int into an object
Int provides less flexibility as compare to Integer as it only allows the
binary value of an integer in it. The Intege on the other hand is more
flexible in storing and manupulating in data since wrapper class inherit
object class.
Posted by: Guest on December-05-2020
1

long vs int java

An int is a 32-bit integer; a long is a 64-bit integer. Which one to use depends on how large the numbers are that you expect to work with.

int and long are primitive types, while Integer and Long are objects. 
  
  Primitive types are more efficient, but sometimes you need to use objects;
for example, Java's collection classes can only work with objects, 
so if you need a list of integers you have to make it a List<Integer>, for example (you can't use int in a List directly).
Posted by: Guest on August-15-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language