| Author |
Boxing vs VarArgs
|
RakeshRanjan Ranjan
Greenhorn
Joined: Nov 17, 2006
Posts: 3
|
|
I have taken this question from John Meyer's exam and slightly modified it. Can anyone please explain me the output ? class test { public static void main(String[] args) { test inst_test = new test(); inst_test.method ( 1 , 1 , 1); inst_test.method( new Integer(1) , new Integer(2) , new Integer(3) ); inst_test.method ( 1 , new Integer(5) ); inst_test.method ( new Integer(10) , 1 ); } public void method( Integer a,Integer b, Integer c ){ System.out.println("Eye in the sky"); } public void method( int... i ){ System.out.println("Fly in the pie"); } } I am getting the floowing output .. Eye in the sky Eye in the sky Fly in the pie Fly in the pie I thought it will always print "Eye in the sky"
|
 |
Burkhard Hassel
Ranch Hand
Joined: Aug 25, 2006
Posts: 1274
|
|
Hi ranchers, RakeshRanjan Ranjan posted December 01, 2006 02:58 AM
I thought it will always print "Eye in the sky"
you were right, if you passed three of them. Bu.
|
all events occur in real time
|
 |
 |
|
|
subject: Boxing vs VarArgs
|
|
|