• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Generic Array creation Doubt

 
Ranch Hand
Posts: 166
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ranchers

why does the code at line 1 gives me a compiler error?

Gen1<String> arr[] = new Gen1<String>[5]; //line 1
arr[0] = new Gen1("Java"); //line 2
arr[1] = new Gen1(1); //line 3

I get compiler error at line 1 saying "Generic Array Creation".
Can anyone explain me what does this statement mean
Gen1<String> arr[] = new Gen1[5];

Thanks
Srividhya
 
Ranch Hand
Posts: 486
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am also geeting this error:

Exception in thread "main" java.lang.Error: Unresolved compilation problems:
The type Gen is not generic; it cannot be parameterized with arguments <String>
The type Gen is not generic; it cannot be parameterized with arguments <String>

at Gen.main(Gen.java:14)
 
Marshal
Posts: 79178
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think you are getting different errors. Srividhya: read this from Angelika Langer. Use ctrl-f then array, and try a search through the Ranch. This problem comes up every few weeks.

Dinesh: Don't know, but I would suggest you believe the error message and check out the Gen class file.

[edit]Tried to Correct URL tags[/edit]
[ May 05, 2008: Message edited by: Campbell Ritchie ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic