• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

generics question

 
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
this is from javabeat.net


Ans d
Can anyone exlain me why it is giving compiler error?

I think because two methods hold valid for the given call --> method3 and method5. Is it the reason it is giving compiler error?
thanks,
Geeta V
 
Ranch Hand
Posts: 137
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,



all of the statements above will result as the following statement after removing generic type information:



hence the compiler will report them as duplicate method declaration!

Always remember that generic type information is only valid at compile time. when the code is compiled, all generic type information is removed from the code.

Hope this helps!
 
Ranch Hand
Posts: 352
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes 'M' is right, the methods are not correctly overloaded, as the basic requirement in overloaded methods is to change the argument list.

The generics tag does not fulfill this requirement as the compiler simply sees a List Object in all the Methods called l1 and l2:


 
Is this the real life? Is this just fantasy? Is this a tiny ad?
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic