File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
Badass: Making Users Awesome
this week in the
Programmer Certification (SCJP/OCPJP)
Joined: Oct 09, 2006
Oct 26, 2006 19:15:00
public <T> List<T> meth(List<?> type)
System.out.println(type); // 1
>(); // 2
Line 1 compiles fine.
Line 2 Fails. Reason : List Required
Cant we return a
where List is required???
I think we can return the subclass right.
Sid<br />SCJP 1.5<br />SCBCD (Preparing....)
Joined: Feb 07, 2005
Oct 26, 2006 19:41:00
Actually the error message from the compiler is
found : java.util.ArrayList<java.lang.String> required: java.util.List<T>
It's not saying that you can't return an
It's saying it expects you to return a List whose elements are the type parameter T.
I agree. Here's the link:
subject: Generics Question
how can I add some stuff in returned List?
John Meyers's SCJP mock errata
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2015