AchrefELMOUELHIc G List Java List ArrayList LinkedList Vector H H: Research and Training 6 / 50 set(index, object) : remplace la valeur de l' élément d'indice index de la liste par object Collections sort(lettres); // pour trier la liste
coursJavaCollection
sort(T[] a, int fromIndex, int toIndex, Comparator
VIII Les collections
stores an Integer object for each value ArrayList stores the elements contiguously in an array Sorting: the order of keys can be random or sorted ( using
High Performance Lists in Java JavaZone
in Java, List is an interface, not a class A plain "ArrayList" accepts any kind of Object • When you "get" an Collections sort( list ); // sorts the menu Sort an
ArrayList
http://developer java sun com/developer/onlineTraining/collections/Collection html ArrayList LinkedList Interfaces Map HashMap TreeMap Par contre, il n' y a pas d'implémentation de l'interface boolean remove(Object element); // Optional sort(List list,Comparator comp) ; trie une liste en utilisant un comparateur
Collections
En Java, l'outil javadoc (fourni avec le JDK) permet de générer une documentation HTML à partir boolean contains(Object o) List est implémentée par ArrayList, Vector, LinkedList, etc Par défaut, Collections sort( List l) utilise l'interface
Complements Java
Sorts the specified array of objects into ascending order, according to the natural import java util List; import java util ArrayList; import java lang Comparable;
ter Cours Comparable Comparator
1 1 00 Lecture 34 Sorting Reading for next time: Big Java 15 4 Comparable interface • Used to define the natural order of objects Exam Test: Sort ArrayList
MIT S Lec