Salut,

je voudrais générifier ce code :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
public static List listLength(List list) {
       ArrayList length=new ArrayList();
       for(int i=0;i<list.size();i++) {
         CharSequence seq=(CharSequence)list.get(i);
         length.add(seq.length());
       }
       return length;
     }
     public static void main(String[] args) {
       List l=Arrays.asList(args);
       System.out.println(listLength(l));
     }
J'ai fait ceci mais ça ne fonctionne pas
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import java.util.*;
 
public class Test<T>{
    public static List<T> listLength(List<T> list) {
	ArrayList<T> length=new ArrayList<T>();
	for(int i=0;i<list.size();i++) {
	    CharSequence seq=(CharSequence)list.get(i);
	    length.add(seq.length());
	}
	return length;
    }
 
    public static void main(String[] args) {
	List<String> l=Arrays.asList(args);
	System.out.println(listLength(l));
    }	    
}
Je voudrais aussi savoir comment ça se fait avec les wilcard

Merci