• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Confusion with the below mentioned code

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
https://coderanch.com/t/455788/Programmer-Certification-SCJP/certification/overriding-meth-String-wih-meth

above thread will solve your all doubt

 
Ranch Hand
Posts: 504
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot........got the point.
 
reply
    Bookmark Topic Watch Topic
  • New Topic