Java-source: Exemple d’utilisation de LinkedHashSet

Author:

Java-source: Exemple d'utilisation de LinkedHashSet
{filelink=472}

/***** Code de MesExemples.com *******/
import java.util.LinkedHashSet;

 class ExempleLinkedHashSet
 {

public static void main(String[] args) {

//créer un objet LinkedHashSet et ajouter des valeurs
LinkedHashSet lhashSet = new LinkedHashSet();
lhashSet.add("A");
lhashSet.add("B");
lhashSet.add("C");
System.out.println ("Taille Avant: "+lhashSet.size());

lhashSet.remove("B");

System.out.println ("Taille Après: "+lhashSet.size());

// parcourir
for(String elem: lhashSet)
   System.out.println (elem);

}
}

Leave a Reply

Your email address will not be published. Required fields are marked *