• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

generic erasure

 
taras khoma
Greenhorn
Posts: 9
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator





what the difference between those codes? I can't understand why the first one does not compile at all and with the second all fine ;(
 
Stephan van Hulst
Bartender
Pie
Posts: 5893
63
  • Likes 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This has nothing to do with erasure. It's just a simple rule. You can go from generic to non-generic, but not the other way around.

It's hard to explain using your example, because the generic type parameters are useless anyway. There's nothing you can do with T that will make the code more useful.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic