This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Arrays of generics Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Arrays of generics" Watch "Arrays of generics" New topic
Author

Arrays of generics

Alina Petra
Greenhorn

Joined: Oct 17, 2006
Posts: 26
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?
 
Don't get me started about those stupid light bulbs.
 
subject: Arrays of generics
 
Similar Threads
Generics Question
method types in Generics
generics question from javabeat
Arrays of generics
javabeat mock test