• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doubt in Generics

 
Rikesh Desai
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Source: http://www.angelikalanger.com/GenericsFAQ/FAQSections/ParameterizedTypes.html#FAQ001



I am not able to understand how the line marked in red (Line 1) is giving error?
 
Ankit Garg
Sheriff
Posts: 9509
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The declaration of Name class given in the tutorial is

Since Name is a sub-class of Pair, you can't directly assign a super class object to a sub-class reference...
 
Rikesh Desai
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
oh, I missed seeing that line!
Thank you Ankit for your quick response!

I am stuck at one more place..

same source:



Arrays holding elements whose type is a concrete parameterized type are illegal.


I am not able to understand the reason given by them for the same.
What is wrong in an array having elements whose type is a concrete parameterized type?
 
Arjun Srivastava
Ranch Hand
Posts: 432
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am not sure if this is the problem but i guess you can't instantiate generic array.
see this.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic