import java.util.HashSet;Sortie:
import java.util.List;
import java.util.ArrayList;
public class ToArrayList{
public static void main(String[] args) {
// Créer une HashSet
HashSethset = new HashSet ();
//ajouter les éléments à HashSet
hset.add("java");
hset.add("C");
hset.add("C++");
hset.add("Objective C");
hset.add("HTML/CSS");
// imprimer la liste HashSet
System.out.println("HashSet : "+ hset);
// Créer une ArrayList de type générique String
//et passer hashset comme argument
ArrayListarraylist = new ArrayList (hset);
// imprimer ArrayList
System.out.println("ArrayList : "+ arraylist);
}
}
HashSet : [HTML/CSS, C, java, Objective C, C++]
ArrayList : [HTML/CSS, C, java, Objective C, C++]
Please disable your ad blocker and refresh the window to use this website.