Re: Converting Sets
On 2/2/12 4:29 PM, Roedy Green wrote:
On Thu, 02 Feb 2012 09:21:13 -0800, markspace<-@.> wrote, quoted or
indirectly quoted someone who said :
I think this is covered in Effective Java. Generics are a compile time
thing
Everything else in Java eventually seems obvious. Generics on the
other hand get weirder and weirder the more I learn. I think it was a
mistake to try to do generics purely at compile time. It is like
trying to do all types purely at compile time.
That is exactly what Generics are.
Have we gone down that road too far now that Java can never be fixed
with run-time generics info without starting over with some completely
different notation? Then serialisation could work, containers could be
allocated with the precise array type. You would not have so much
under-the-hood casting.
The point of generics is to add compile-time type safety. Runtime
"generics" is a contradiction to that. It might not have been
implemented in the "cleanest possible" way, but it tends to be good
enough for most non-reflective uses.
Perhaps it is time to read-read all the generics docs and see if they
make more sense now with some practical experience under my belt.
Yes, probably.
In particular, you want to understand what "<A extends B>" and
"<A super B>" mean when declaring generic types, and what "<? extends
B>", "<? super B>" and "<?>" mean when /using/ generic types.