class Test{
public static void main(String[] args){
int a = 1;
int b = 5;
Integer c = new Integer(1);
Integer d = 5;
System.out.println(c.compareTo(d));
System.out.println(a.compareTo(b));
}
}
Why a.compareTo(b)doesn't compile ( int cannot be dereferenced)? I know that it compareTorequires objects, but I thought that autoboxing would automatically do inta Integerwhen necessary. Why in this case does not occur auto-boxing? And what other cases will this not happen?
source
share