• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Confusion with the below mentioned code

 
binnu yadav
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator




If I compile this code,get this error message:-
cannot declare both method(java.lang.String,java.lang.String...) and method(java.lang.String,java.lang.String[]) in Overload
final Object method(String name, String... names) {
^
1 error.

Can somebody explain me the concept behind this ?

and If I am trying this code :-


It works fine........

Please make me understand the logic !!!

Regards,

Arun

 
vicky ma
Ranch Hand
Posts: 38
 
Neha Daga
Ranch Hand
Posts: 504
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
because var args works as arrays and both of your methods in the first code seems to have same arguments to the compiler and hence violates the rule of overloadinng that argument list should be different, so it gives compiler error.
 
binnu yadav
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot........got the point.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic