They only accept an instance of the integer class for your test method, which is not a primitive integer java type. integer is a java class, not a primitive int like a String class. long , on the other hand, is a primitive type and has a subset of int , so it selects this option because it is the closest match. You can also try using a double parameter. When int or long is the absence signature in the method parameter, he decided to use double alone, as this is the closest match.
http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Integer.html
try the following:
public static void main(String[] args) { int i = 5; test(i); Integer smartInt= new Integer(5); test(smartInt); }
source share