• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Reference Variable

 
Sid Robin
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


y does a.foo("test") call the method with var arg parameter and not the other foo method ?
 
vaibhav srivastava
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this is because in case of variable parameters , the compiler has no way to understand that you want variable-number-of-string function or the single-string function to be executed.
you are having the reference variable of the super class.
just like foo(String... args,int x) is not valid as one cant understand when this variable list will finish so if you think just for a second from the compiler's perspective.. you will get it !
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic