Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

var-args

 
swaraj gupta
Ranch Hand
Posts: 182
C++ Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Output: 14
Why so..?

How would you read this "int[]..a" ?
Well var-arg is one of my weakest point, I faced same sort of problems when I was going through advanced overloading. How should I fix it..? Please suggest something..
 
Paul Clapham
Sheriff
Pie
Posts: 20750
30
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You pass two parameters to the go() method. What are they? And then the go() method prints... what?
 
swaraj gupta
Ranch Hand
Posts: 182
C++ Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham wrote:You pass two parameters to the go() method. What are they? And then the go() method prints... what?

Just know one thing here that we are passing references of one-dimensional int type array objects to go method.
 
Prasad Kharkar
Ranch Hand
Posts: 446
1
Eclipse IDE MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Swaraj
even var-args was obstacle in my preparation
but it is simple
look you have to just remember some rules

with var-args as method arguments, we can pass either array or various arguments to the method



so the answer is 14

hope this helps
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic