Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how can I add some stuff in returned List?

 
vitesse wei
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic