Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Boxing vs VarArgs

 
RakeshRanjan Ranjan
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1274
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic