*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes how can I add some stuff in returned List? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "how can I add some stuff in returned List?" Watch "how can I add some stuff in returned List?" New topic
Author

how can I add some stuff in returned List?

vitesse wei
Ranch Hand

Joined: Sep 07, 2007
Posts: 100
code :
import java.util.*;
class test{
public static void main(String[] args){
test t = new test();
List<String> l = new ArrayList<String>();
l.add(new String("abc"));
l.add(new String("def"));
System.out.println(t.meth(l));
}
public <T> List<T> meth(List<?> type)
{
System.out.println(type); // 1

return new ArrayList<T>();// 2
}
}

line 1 print the content of l,line 2 construct a List,what kind of Object in it?,is there somewhere i can code to add element to it?


SCJP 5.0<br />SCWCD1.4<br />SCBCD5
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343



"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
 
jQuery in Action, 2nd edition
 
subject: how can I add some stuff in returned List?