• Post Reply Bookmark Topic Watch Topic
  • New Topic

Generic arrays  RSS feed

 
Joe Harry
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why is that we get compilation failures when we try to create generic arrays?
 
Campbell Ritchie
Marshal
Posts: 56578
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It has to do with erasure. Search this site; this question has come up before, but not for a few months. There is something on Angelika Langer's website, too. I hope those links answer your question; if not, please ask again.

And this is probably too complicated for the beginner's forum. I shall move you.
 
Peter Lawrey
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have used Java since I worked for Sun in 2000 and this doesn't make sense to me.
The article seems to assume a level of type safety which does not exist.
An example given

However, if you used Collections with erasure, which would compile, the outcome would be no different.

So you can create a generic Collection, but not a generic Array and yet the Array still end ups providing greater runtime safety.
[ December 23, 2008: Message edited by: Peter Lawrey ]
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!