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

Why a generic declaration in a class prevent USE of methods with generic argument?

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Greetings!, I've read the Generics stuff many times, and I also have searched the forum, but my question keep unanswered :-(:
Let's say you have declared these classes:



so, why the following lines are INCORRECT?:



They all fail in compilation time, so, (again), what is the purpose of being able to declare a generic class with the metacharacter '?' if then you cannot use methods with arguments of the generic Type??? (because you CAN use otroMetodo without any problem). It could be to prevent modification of the Generic object received as argument? (It seems a too strong limitation to me!!). Anyway, IMHO, if you cannot USE these kind oh methods, the compiler should alert you in their DECLARATION (because they are useless!), not when you try to use them. Or am i missing something?. Any help/explanation would be very appreciated, thanks!

 
Car Tola
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, I've just discovered that the following is CORRECT:



I understand even less
 
reply
    Bookmark Topic Watch Topic
  • New Topic