long vs int java

Solutions on MaxInterview for long vs int java by the best coders in the world

showing results for - "long vs int java"
Simona
15 Aug 2016
1An 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.
2
3int and long are primitive types, while Integer and Long are objects. 
4  
5  Primitive types are more efficient, but sometimes you need to use objects;
6for example, Java's collection classes can only work with objects, 
7so 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).