Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Boxing vs VarArgs Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Boxing vs VarArgs" Watch "Boxing vs VarArgs" New topic

Boxing vs VarArgs

RakeshRanjan Ranjan

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.


all events occur in real time
subject: Boxing vs VarArgs
It's not a secret anymore!