Bonsoir, j'ai un problème avec ce code, il m'affiche une erreur
je veux supprimer "C" par leur indice
Code : Sélectionner tout - Visualiser dans une fenêtre à part The method binarySearch(List<? extends Comparable<? super T>>, T) in the type Collections is not applicable for the arguments (List<String>, test)
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
18
19
20
21
22
23
24
25
26
27
28
29 import java.util.*; public class test{ public test() {} public test(String a) {} void t() { List<String> etd = new ArrayList<String>(); etd.add(new String("A")); etd.add(new String("C")); etd.add(new String("B")); Collections.sort(etd); for (String m : etd) System.out.println(m); int indice = Collections.binarySearch(etd, new test("C")); etd.remove(indice); for (String m : etd) System.out.println(m); } public static void main(String[] args) { new test().t(); } }
Partager