This code is from
SCJP guide from seira and berts
Please explain me the output of the following code:
public class Bertha{
static
String s="";
public static void main(String args[])
{
int x=4;
Boolean y=true;
short [] sa={1,2,3};
doStuff(x,y);
doStuff(x);
doStuff(sa,sa);
System.out.println(s);
}
static void doStuff(Object o)
{
s+="1";
}
static void doStuff(Object... o)
{
s+="2";
}
static void doStuff(Integer...i)
{
s+="3";
}
static void doStuff(Long l)
{
s+="4";
}
The output of the code is 212
When the doStuff method is called second time,an integer variable is passed
to the method,but still the method with Object argument is called instead of method
with var-args of Integer?Can anyone explain this behaviour?