How to check if HashSet is empty in Java

1 Answer

0 votes
import java.util.*;

public class MyClass {
    public static void main(String args[]) {
        Set<String> letters = new HashSet<>(Arrays.asList("a", "b", "c", "d", "a", "a", "e"));
      
        System.out.println(letters.isEmpty()); 
    }
}




/*
run:

false

*/

 



answered Feb 16, 2021 by avibootz

Related questions

1 answer 158 views
158 views asked Nov 30, 2016 by avibootz
1 answer 182 views
1 answer 212 views
1 answer 230 views
2 answers 196 views
1 answer 205 views
...