Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Generics

 
Juan Manuel Alberto de los Santos
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Why this compiles ??

if i am passing an object(animal) to the method go (who can only accept integers)

Thanks in advance !
[ July 09, 2008: Message edited by: Juan Manuel Alberto de los Santos ]
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It compiles so generics are compatable with legacy code. However, you will have seen a warning:

Type safety: The expression of type List needs unchecked conversion to conform to List<Integer>

letting you know what you are doing is not necessarily safe.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic