import java.util.HashSet;
import java.util.Set;
public class IsEmpty {
public static void main(String[] args) {
Set<String> hs = new HashSet<String>();
hs.add("java");
hs.add("php");
hs.add("html");
hs.add("javascript");
hs.add("mysql");
//print hashset
System.out.println("hashset = "+hs);
System.out.println(hs.isEmpty());
HashSet<String> hs2 = new HashSet<String>();
System.out.println(hs2.isEmpty());
}
}
Output:
hashset = [javascript, php, html, java, mysql]
false
true
import java.util.Set;
public class IsEmpty {
public static void main(String[] args) {
Set<String> hs = new HashSet<String>();
hs.add("java");
hs.add("php");
hs.add("html");
hs.add("javascript");
hs.add("mysql");
//print hashset
System.out.println("hashset = "+hs);
System.out.println(hs.isEmpty());
HashSet<String> hs2 = new HashSet<String>();
System.out.println(hs2.isEmpty());
}
}
Output:
hashset = [javascript, php, html, java, mysql]
false
true
No comments:
Post a Comment