What's the difference between between Integer and int and when is either of them use? | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
0

What's the difference between between Integer and int and when is either of them use?

12th Oct 2020, 10:27 PM
Sunday Othniel
Sunday Othniel - avatar
3 Respuestas
+ 3
int is a primite data type. Integer is a class, object. But have something call wrapp and unwap, calling one for other is possible because it (transform one on another, so same thing). ATTENTION: calling new Integer(number) is DIFERENT to number. It's because "new" create a new object.
13th Oct 2020, 12:29 AM
Marcelo Anjos
Marcelo Anjos - avatar
0
int is keyword to define integer in java. But integer itself is a data type.
12th Oct 2020, 11:18 PM
🇮🇳Vivek🇮🇳
🇮🇳Vivek🇮🇳 - avatar
0
Collection api and generic<Type> declarations requires Integer instead of int new Integer(n); is deprecated
13th Oct 2020, 7:10 PM
zemiak