Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question 9 from Examlab practice exam 1

 
Henry Dai
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi, all , i have a question on var-arg. why line#1 invoke method 2 instead of method 5. Isn't that var-arg will be last considered? int[] is also an object, why it didnt choose method 5 over method 2. Could someone please explain, thank you!
 
Devaka Cooray
ExamLab Creator
Marshal
Pie
Posts: 4319
236
Chrome Eclipse IDE Google App Engine IntelliJ IDE jQuery Postgres Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
var-arg parameters can accept arrays too. For an array argument, a var-arg parameter is more appropriate, other than passing it to a parameter with java.lang.Object type.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic