• 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
  • Ron McLeod
  • Junilu Lacar
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Piet Souris
  • Carey Brown
  • Stephan van Hulst
Bartenders:
  • Frits Walraven
  • fred rosenberger
  • salvin francis

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?
 
Surfs up space ponies, I'm making gravy without this lumpy, tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic