Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Generics

 
Set Lonnert
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Having trouble with comprehending generics, especially the wildcard addition. Perhaps there is someone here which could tell me about how to circumvent the oddities of type conversion in the following ...

What am I thinking wrong?

(Ok, I've studied a bit about GJ, Pizza, NextGen etc. but still ... doesn't get things right, yet.)



Regards!
/Set Lonnert
 
Set Lonnert
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm sorry if my posting is somewhat cryptic? In any way, I should perhaps be more verbose? In the code followup, kind of:



my problem is the lack of type casting give compiler warnings, warnings which I have really no idea how to handle? Casting down to what becomes raw types give me a, kind of, headache. Or at least the compiler thins so. Could anyone give me an idea on how to handle casts (with-) in type parameters correctly, that will not give unsafe type conversions? Any short sample will do, not necessarily referring to the above. (My prevois experience derives from logic, but here the logic seems to be only erasure compatible with ordinary Java. Hm.)

Regards!
/Set Lonnert
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34837
369
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Set,
Welcome to JavaRanch!

Are you compiling in 1.5 compatibility mode? What kind of compiler warnings do you get?
 
Set Lonnert
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for having me

Yes I compile using the 1.5 or whatever version numbering they use these days. These are approx. the warnings I get:


Should there be wrappers to avoid implicit conversions to raw types (most frequent
warning), or should there perhaps be a wildcard somewhere (as mentioned, I don't yet
understand its significance)? Any ideas are most welcome ...

Regards!
/Set Lonnert
PS. I was here years ago, but then there were to few to mention
.. no talk to I mean
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic