Can I use compareTo to sort integer and double values? My system gives me an error that I Cannot invoke compareTo(int) on the primitive type int. any ideas?
Code:
In your current code; easier solution would be to just change this line and all will be good:
return o1C.getPrice() - o2C.getPrice() ;
This would work fine and good performance too because method compare() has only following requirement viz. return zero if both values are equal; else a positive/negative number.