+ 1
I noticed that int X; and Integer X; in Java can mean two different things. Is there a difference? Why is that the case?
Java
3 odpowiedzi
0
Yes it’s a special object that works just like the primitive version, you would use this version in generics since it only works on classes
+ 1
int is a primitive type, Integer is the class for it.
+ 1
OK so when I want to declare and initialize a variable as Integer x = 2; instead of int x = 5;
does it mean I just declared and initialized a class?