Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Arrays of generics

 
Alina Petra
Greenhorn
Posts: 26
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which of the following lines can be compiled?

a)Basket<Apple>[] b = new Basket<Apple>[10];

b)Basket<?>[] b = new Basket<Apple>[10];

c)Basket<?>[] b = new Basket<?>[10];

d)public <T> T[] test() {return null;}

e)public <T> T[] test() {return new T[10];}

Can anyone give the right answer followed by explanation?
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic