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
The Mikado Method
this week in the
Agile and other Processes
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:
- if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
subject: Generics Question
John Meyers's SCJP mock errata
how can I add some stuff in returned List?
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2013