import java.util.HashSet;Output:
public class HashSetremove{
public static void main(String[] args) {
HashSet< Строка> hashset = новый HashSet< Строка> ();
hashset.add("v1");
hashset.add("v2");
hashset.add("v3");
hashset.add("v4");
hashset.add("v5");
System.out.println("HashSet перед удалением: "+hashset);
Объект e = "v2";
boolean b = hashset.remove("v2");
System.out.println("удален элемент "+e+": "+b);
System.out.println("HashSet после удаления "+e+": "+hashset);
}
}
HashSet before remove: [v1, v5, v4, v3, v2]
v2 элемент удален: true
HashSet после удаления v2: [v1, v5, v4, v3]
Please disable your ad blocker and refresh the window to use this website.