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

Doubt regarding overloaded method example  RSS feed

 
Mansukhdeep Thind
Ranch Hand
Posts: 1163
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

Following is an assignment question in SCJP for java 5 book:


The answer is -434

Can someone explain how ? In what order are the methods called and why?
 
Campbell Ritchie
Marshal
Posts: 55687
163
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Start by writing down very carefully what the four methods are, and what their parameters are (ie their signatures)..
 
Mansukhdeep Thind
Ranch Hand
Posts: 1163
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:Start by writing down very carefully what the four methods are, and what their parameters are (ie their signatures)..


Got it sir. Arrays are objects too. hence the -434. Was a tricky one though..
 
Campbell Ritchie
Marshal
Posts: 55687
163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, an array is an object. The Foo[]... versions are equivalent to Foo[][] and you don’t have any arrays of arrays in that code.
 
Mansukhdeep Thind
Ranch Hand
Posts: 1163
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:Yes, an array is an object. The Foo[]... versions are equivalent to Foo[][] and you don’t have any arrays of arrays in that code.


As borat says, HIGH 5!
 
Campbell Ritchie
Marshal
Posts: 55687
163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!