int a,b,c;
if (a == null) {
//code here
}
This code doesn't make sense, because primitive int
types cannot be null. Even if you considered auto-boxing, int a
is guaranteed to have a value before being boxed.
Integer a,b,c;
if (a == null) {
//code here
}
This code makes sense, because Object Integer
types can be null (no value).
As far as the functionality, the Object vs built-in types actually do make a bit of a difference (due to their different natures).
Integer a,b,c;
if (a == b) {
// a and b refer to the same instance.
// for small integers where a and b are constructed with the same values,
// the JVM uses a factory and this will mostly work
//
// for large integers where a and b are constructed with the same values,
// you could get a == b to fail
}
while
int a,b,c;
if (a == b) {
// for all integers were a and b contain the same value,
// this will always work
}