Java-source: Parcourir et afficher le contenu de LinkedHashSet

Author:

Java-source: Parcourir et afficher le contenu de LinkedHashSet
{filelink=469}

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

 class ParcourirLinkedHashSet
 {

public static void main(String[] args) {

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


Iterator itr = lhashSet.iterator(); 
System.out.println("LinkedHashSet contient : ");
while(itr.hasNext())
System.out.println(itr.next());

}
}

Leave a Reply

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