• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

What does it mean ?

 
Ranch Hand
Posts: 584
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,

What does the following affirmation mean ?

"All instances of a generic class have the same runtime class, regardless of their actual type parameters. So it is not meaningful to use the instanceof operator to check if an object is the instance of a particular invocation of a generic type."

Could you please explain by using code ?

Thanks
 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An example: ArrayList<String> list1, ArrayList<List> list2, ArrayList<Integer> list3, ArrayList<Double> list4 are all reduced to the raw type ArrayList at runtime. So you can only ask if list1 instanceof ArrayList, or list2 instanceof ArrayList, and so on. You cannot ask if list1 instanceof ArrayList<String> or list2 instanceof ArrayList<List>
 
Edisandro Bessa
Ranch Hand
Posts: 584
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
*Bump*. Now I see. Now it's clear.

Thank you Sir.
[ April 18, 2006: Message edited by: Edisandro Bessa ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic