Because int
is a primitive type, not a class, thus it is not directly comparable to String
. The corresponding class type is Integer
, spelled according to the class naming conventions.
Similar pairs of primitive and class types are
byte
vsByte
short
vsShort
long
vsLong
float
vsFloat
double
vsDouble
boolean
vsBoolean
char
vsCharacter