• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

Arrays of generic types

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

Is it possible to create reference variables of arrays of generic types like:

OR


Here, I found that we can declare a reference variable of an array type whose component type generic. But all such variable can refer is null, an array whose component type is a non-parametrized subtype of the reference variable component type or corresponding raw type (List[]).

But when I try to declare reference variable to an array of generic type I get an error that "arrays of generic types are not allowed". I know they are not but the FAQ says that declaration of a reference variable to an array of generic type IS allowed. Can someone check is this true. My compiler rejects such declaration. I have 1.5.0-beta version and I compile with -source 1.5 flag.

One more question. Do I have to learn all the details of generics in order to pass SCJP 1.5? I have read K&B book, but the chapter about generics is too short and doesn't explain generics in detail. I had problems with questions about generics on the self test after the chapter. So I decided I have to strengthen this objective and I found this useful FAQ. But it is so big. Do I have to know all the details about type erasure, bridge methods or subsuitable return types for the SCJP? Do you have a link to generics tutorial that is not so advanced but enough to pass SCJP?

Thanks.
[ August 29, 2007: Message edited by: Jan Nowak ]
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your questions is answered in Angelika Langer's FAQ which you already found: Can I create an array whose component type is a concrete parameterized type?
 
Don't destroy the earth! That's where I keep all my stuff! Including this tiny ad:
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic