Write a program using hashset to add the a,b,c alphabet and remove the c alphabet and displayed the set and size of this set.
import java.util.HashSet;
public class simplehashset {
public static void main(String[ ] args) {
HashSet<String> set = new HashSet<String>();
set.add("A");
set.add("B");
set.add("C");
System.out.println(set);
set.remove("A");
System.out.println(set);
System.out.println(set.size());
}
}
OUTPUT:
[A, B, C]
[B, C]
2
No comments:
Post a Comment